It works, thanks simon.

By the way, is it possible to add some extra attribute to the form works as
a validator, so that the validator could be run before submit, if it
returns false, just stop submit. In that case, this will decrease a little
bit work.

On Mon, Apr 2, 2012 at 2:32 AM, simon <simo...@gmail.com> wrote:

> The submit is trapped by web2py.js
>
> This can be prevented by adding " _class=no_trap" to the form.
>
>
> On Sunday, 1 April 2012 16:50:18 UTC+1, Ronghui Yu wrote:
>>
>> Hi, All,
>>
>> I have a piece of HTML that generated by LOAD helper. And there is a form
>> in it, quite similar to that component plugin_comment described in web2py
>> online book.
>> The problem I have now is, I want the prevent the form submitting if
>> failure to validate some fields, but I am not able to do that even I have
>> the javascript like below, which works for forms not in a component
>>
>> <script type="text/javascript">
>>       jQuery(document).ready(**function(){
>>             jQuery("#someform").submit(**function(event) {
>>                   if (fail_to_validate()) {
>>                       event.preventDefault();
>>                       return false;
>>                    }
>>            });
>>     });
>> </script>
>>
>> I found that the form will always be submitted event with ajax_trap=True
>> or ajax_trap=False, and with or without the above script.
>> Anyone could give me some clue?
>>
>> Thanks in advance.
>>
>> --
>> ===========================
>> Regards
>> Ronghui Yu
>>
>


-- 
===========================
Regards
Ronghui Yu

Reply via email to