Open justdave opened 10 years ago
See also #2
HTML5 has some built in form validation, so you might not need to use jQuery for this. What type of data would you like to validate?
The built in form validation only fires when you use the real form submit button, so it doesn't trigger when I do the ajax-based form submit.
It appears that you can trigger the form validation by triggering a click event on the form Submit button, which you just have to trap to prevent it from submitting the normal way. The form validation appears to be triggered by the click event and not by the actual submit event, so you have to actually emulate a click on the button.
Accomplished a bunch of this with the inputmask plugin for jQuery. Use of the :invalid selector in CSS allows the HTML5 built-in validation to trigger in most browsers (automatic red border in real time on fields that don't have correct values). pattern="" html attribute takes a regexp with legal values. Works way cool these days.
I really want to get client-side form validation working on the forms, but I'm still pretty new to jQuery and I'm finding about 10 different conflicting ways to do it in Wordpress (none of which are actually built into either WordPress or jQuery core). So I'm filing a bug report so someone with more familiarity with jQuery can grab this and work on it while I skip that and go tackle something else. :-)