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

Textareas without maxlength assigned evaluate as non-valid if no value entered #75

Closed SherriAlexander closed 11 years ago

SherriAlexander commented 11 years ago

If you have a textarea (which is not marked "required") and that does not have a maxlength assigned, the script evaluates it as non-valid if you do not enter any text into that textarea. This effectively forces you to specify a maxlength if you want the textarea to validate properly (which is an okay workaround, but not optimal).

So for example, if you have a textarea defined like so:

<textarea name="location-still-looking"></textarea>

and you tab out of it without filling anything in, the script evaluates it as non-valid.

Add a maxlength value (of 5000, let's say), and it evaluates correctly if you don't add any text to the textarea and tab out.

ericelliott commented 11 years ago

Please post a test case on jsfiddle.net

ericelliott commented 11 years ago

http://tinker.io/e6644

Tested in IE8, Firefox, Safari, Chrome. Also, h5Validate passes all the existing tests in IE8 - IE10, Firefox, Chrome, Safari, and Android.

If you're still convinced this is an issue, please provide the specific browser and a test case on http://tinker.io verifying that it doesn't work.

SherriAlexander commented 11 years ago

Sorry for the delayed response -- I was out on a family vacation without a laptop. I will see what I can put together for you by end of day tomorrow. Thanks!

SherriAlexander commented 11 years ago

Ah -- it seems that the behavior is only happening when using jQuery version 1.4 along with h5Validate 0.9.0, which is the combination that we're using on this particular legacy website (which depends on some very old jQuery plugins).

http://tinker.io/35d91/7

Looks like the problem goes away once you get up to jQuery version 1.6.x.

Sorry to bother you with this (as older versions of jQuery aren't within your control) -- but at least hopefully this thread will be useful to anyone else running into a similar problem developing for a legacy site with older versions of jQuery. Thank you for your time!

--Sherri

ericelliott commented 11 years ago

1.4 is going way back. My recommendation is to figure out a way to get them on a newer version of jQuery, instead of clinging to the past.