You should call your js functions within the 'onsubmit' attr from the
form. Something like this:
[code]
<form action="x.php" onsubmit="doThisHere(this);" id="frm_01">
...
</form>
<script type="text/javascript">
var doThisHere = function(myForm)
{
var form = $(myForm);
var valid1 = new Validation(form);
if (valid1)
alert('This form has been validated');
else
alert('Oh boy, you should correct some errors');
}
</script>
[/code]
I hope it helps :)
On Tue, May 12, 2009 at 4:50 AM, MrEnglish <[email protected]> wrote:
>
> Hi!
>
> In my app I previous had a form using field validation. I therefore
> hade the following after the form.
>
> <script type="text/javascript">
> var valid1 = new Validation('myform');
> </script>
>
> This works fine. I have now modified things and I know want to update
> som elements after the form has returned a successfull value. For
> testing i removed the validation and added this:
>
> <script type="text/javascript">
> function dosubmit( ) {
> new Ajax.Updater( 'result', './test.php', { method: 'post',
> parameters: $('myform').serialize() } );
> $('myform').reset();
> }
> </script>
>
> This work as it should for me submitting the form and returning a
> value for the div 'result' to be updated with. The difference in the
> form is that I now have a button with onsubmit, instead of a input
> type="submit".
>
> My question is how I now get to validate the form as before before the
> function dosubmit is run?
> >
>
--
Believe nothing, no matter where you read it, or who said it, no
matter if I have said it, unless it agrees with your own reason and
your own common sense.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---