Sorry to be abrupt, but "return valid.validate()" is terminating this 
function. the "new Ajax.Updater..." is never going to execute. This 
should work:

function dosubmit() {
    if (valid.validate()) {
       new Ajax.Updater( 'result', './test.php', { method: 'post',
           parameters: $('myform').serialize() } );
       $('myform').reset();
    }
}

MrEnglish wrote:
> Hi
>
> Not quite. The validation is a library that does the stuff for me! I
> have changed thing a it that almost works:
>
> <form id="myform" onsubmit="dosubmit()">
> ...
> </form>
>
> under the form I have the following:
>
> <script type="text/javascript">
>   var valid = new Validation('myform');
>
>   function dosubmit() {
>     return valid.validate();
>
>     new Ajax.Updater( 'result', './test.php', { method: 'post',
>       parameters: $('myform').serialize() } );
>     $('myform').reset();
>   }
> </script>
>
> Now, this validates the form like is should and the return
> valid.validate() stoppes the form from beeing submitted if the form is
> not validated. However, when the form is validated, the script is not
> executing the Ajax.Updater bit?
>
>
> On May 12, 2:28 pm, Douglas <[email protected]> wrote:
>   
>> 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.
>>     
> >
>   
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 8.5.325 / Virus Database: 270.12.27/2111 - Release Date: 05/12/09 
> 18:03:00
>
>   


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to