jzaefferer/jquery-validation — Issue #227: Input element without 'type' attribute is never verified on focus events.
Author: jjabba
Created: 2011-10-12 23:02:37+00:00
State: open

Yesterday I made a proof of concept page based on the topmost example at http://docs.jquery.com/Plugins/validation

The input fields in that example does not have a 'type' attribute set. After some debugging I found out that jQuery validation requires the type attribute for focus related validation to trigger.

The type attribute is however NOT required for valid HTML 4.01 Transitional/Strict. And currently jQuery Validation fails silently.

A focus event starts by triggering the function:
line 1187:

$.extend($.fn, {
validateDelegate: function(delegate, type, handler) {
return this.bind(type, function(event) {
var target = $(event.target);
if (target.is(delegate)) {
return handler.apply(target, arguments);
}
});
}
});

the "target.is(delegate)" call failes of the input element lacks type attribute. The delegate is a selector string containing:

"[type='text'], [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime], [type='date'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] "

Since valid html doesn't require a type for input elements and all (most?) browsers treat inputs without type as text inputs I think validator should to.