Apr 29, 2012, 6:48 PM
[CLOSED] DirectEvents + MVC + client side validation: prevent direct event on invalid form
Hey Guys.. I am struggling with trying to figure out how to prevent the direct event from firing if a form doesn't validate on the client side.
Consider a login form (username, password). I just want to make sure that the login button doesn't submit if both fields are empty.
Any suggestions? I'm sure I'm missing something simple.
To work around it for now, I just made a plugin for the form and dropped a click listener for that button to call a method which runs the validation and posts.. but then that requires me to handle the redirect to login page and all that junk which the Direct Event handled for me. I'd rather use the direct event if I can figure out how to stop the event on an invalid form.
[EDIT]
I've tried hooking into the Before handler on the direct event and returning false if not valid, but it still posts to the url.
Thanks.
Consider a login form (username, password). I just want to make sure that the login button doesn't submit if both fields are empty.
Any suggestions? I'm sure I'm missing something simple.
To work around it for now, I just made a plugin for the form and dropped a click listener for that button to call a method which runs the validation and posts.. but then that requires me to handle the redirect to login page and all that junk which the Direct Event handled for me. I'd rather use the direct event if I can figure out how to stop the event on an invalid form.
[EDIT]
I've tried hooking into the Before handler on the direct event and returning false if not valid, but it still posts to the url.
Thanks.
Last edited by Daniil; Apr 30, 2012 at 5:13 PM.
Reason: [CLOSED]