Tuesday 15 June 2010

javascript - Stuck in infinite loop while trying to intercept form submission -


I am writing javascript / jquery code, where i want to stop form submission before submitting it because i have to check Whether the fields are valid.

So I stop the default event from happening, what do I want, then put the event back on fire if everything is okay. The problem is that it triggers a similar function and I get stuck in the infinite loop.

Is there a way around this? I can think of the work around, but after all they do the work around and the solution is not the most elegant.

Here's my code:

  $ ("# Register_form"). Submit (function (event) {event.preventDefault (); console.log ('try submitting form'); check user name (); $ ("# register_form"). Submit ();});    

To be able to stop the form of depositing in errors, Try it

"). Submit (function (event) {if (check Usman () returned), Return Return;});

Or better than ...

  $ ("# register_form"). Submit (function (event) {check check username ();});    

No comments:

Post a Comment