ericelliott / h5Validate

An HTML5 form validation plugin for jQuery. Works on all major browsers, both new and old. Implements inline, realtime validation best practices (based on surveys and usability studies). Developed for production use in e-commerce. Currently in production with millions of users.
576 stars 125 forks source link

Support for multipart forms? #19

Closed tmikaeld closed 12 years ago

tmikaeld commented 12 years ago

It would be great if this plugin could support multipart forms, for example validating a div with fields at a time.

ericelliott commented 12 years ago

I'm not sure what you mean. Could you give me a more detailed use-case?

tmikaeld commented 12 years ago

I'm making a form with several steps, and i wan't to validate each step before the user can continue to the next. It's not really a problem now, since i found $('#myField').h5Validate('isValid') and $('myForm').h5Validate('allValid); in you'r comment. I'm implementing them right now. Though it would be better if i could validate-check a whole fieldset, is that possible?

ericelliott commented 12 years ago

You could make them separate forms. Make the user clear 'allValid' on one before you enable the next... You can run as many instances of h5Valiadate as you want on the same page. It's totally instance safe.

ericelliott commented 12 years ago

Or don't make them separate forms, just use a classname selector for the different parts?: $('.step1').h5Validate(), $('.step2').h5Validate(), etc..

tmikaeld commented 12 years ago

So if i add the class to each field, then validate, it will validate-check them all? That's really neat :-)

tmikaeld commented 12 years ago

But you mentioned that isValid changed, so the new method is to use $('.step1').h5Validate() in an if statement and it will return true false?

EDIT: Nevermind, i saw that isValid is still in use, just changed a little.

tmikaeld commented 12 years ago

I also noticed that this uses jQuery 1.4.2, is it safe to use with jQuery 1.6.4?

ericelliott commented 12 years ago
  1. The usage for isValid has not changed. What has changed is that it will now automatically detect if it needs to validate the field.
  2. I have not tested against 1.6.4, but I think it should work. If you're using it, you might want to verify that your validation works as expected. I'm planning to update and test this weekend.
tmikaeld commented 12 years ago

That's great. I'll test it with 1.6.4 as much as i can, you might find an automated testsuite useful. If i get the time, i'll try and build a testsuite for it.

And thanks for a great plugin, it's the best html5 validator plugin i have found (and i think i have tried them all).

ericelliott commented 12 years ago

A testsuite is definitely coming. I want to use QUnit: http://docs.jquery.com/QUnit

I would LOVE help. =)

I appreciate the help and comments.

tmikaeld commented 12 years ago

I have a tight deadline for the project i'm on right now, but once i'm done i can try and help out. I haven't made a unit tester before, but it will be very much worth the experience.

ericelliott commented 12 years ago

I started a test suite. It's not 100% coverage, but it covers the basics. Upgraded to jQuery 1.7. All tests pass in IE7 - IE9, Chrome, Safari, Android browser, and Opera. Will test iOS tomorrow. Check it out.

tmikaeld commented 12 years ago

Wow, amazing work dilvie! I will be sure to check it out once i have time :-)

EDIT: I checked the source just now, simple but effective ;-)

ericelliott commented 12 years ago

Feel free to add some tests. I'd love to have better coverage. Especially better coverage of the built-in patterns. =)

I want to cover allValid, as well, but I think I'm about to make some changes to how that works. (Planning to trigger an event and pass out a list of invalid fields from it).