Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Implement jQuery form validation #15

Open
justdave opened this issue Sep 20, 2014 · 5 comments
Open

Implement jQuery form validation #15

justdave opened this issue Sep 20, 2014 · 5 comments

Comments

@justdave
Copy link
Member

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
Copy link
Member Author

See also #2

@pburtchaell
Copy link

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
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

justdave commented Nov 8, 2014

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.

justdave added a commit that referenced this issue Nov 8, 2014
Implements most of #13, #14, and #15.  Doesn't submit anything to the database yet, but the form UI is mostly there.
Form reset between scouts is broken and I can't figure out why.
Doesn't handle last scout or final form submission yet.
Mostly just in a good enough state to use as a demonstration at a meeting later today.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants