oabsa / election-manager

Wordpress plugin specifically designed to collect election results from a BSA Order of the Arrow election
GNU General Public License v2.0
3 stars 0 forks source link

Implement jQuery form validation #15

Open justdave opened 10 years ago

justdave commented 10 years ago

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. :-)

justdave commented 10 years ago

See also #2

pburtchaell commented 10 years ago

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?

justdave commented 10 years ago

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.

justdave commented 9 years ago

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.

justdave commented 9 years ago

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.