In 1.10.0, min/max validation was supported for input type="text",
where min/max were interpreted as numbers. This means min/max
for date would not work: min="2012-02-13" was interpreted as min="Not a Number".
In 1.11.0, min/max were no longer converted to numbers. This means
min/max for dates worked, but min/max for numbers failed:
"50" < "150" < "1000" does not hold.
For an example, see http://jsbin.com/awokex/3
This commit makes the behaviour of min/max dependent on input type:
* input type=text (or not type attribute) has numeric min/max, as in 1.10.0
* input type=date has working min/max for type date;
on mobile browsers you also get a date picker,
plus the browser may reject invalid dates before
javascript gets a chance to complain.
* input type=number or range get numeric min/max,
plus numeric keypad or slider on mobile browsers,
plus browser may reject invalid input before javascript
gets a chance to complain
Allowing use of min/max with type=number/range/date is important
for mobile browsers, where the numeric keypad or date picker
make the input much easier to use than a generic text input field.
In this situation jquery-validate remains necessary to support
older browsers that do not do input validation based on type
and min/max.
For situations where numeric input should be validated by jquery
without giving the browser a chance to validate the input format,
input type=text in combination with min/max can be used, as in 1.10.0.
These rules are fully suitable to check any comparable JavaScript objects such as strings or dates. Also clearing prevents HTML5 date input fields to work when these rules are coming from HTML.
Field names can contain spaces (as they are a CDATA type). This causes problems with groups, as the string listing the fields is split on spaces.
This commit allows the groups option to be either a space-separated string or an array of strings so that field names with spaces can be added. It also adds a unit test to ensure that both string and array based groups are processed into the same data structures.
The validator element() method delegates to check(). When check() is
passed a radio or checkbox input element (call it 'A'), it instead
checks the first element with the same name in the form (call it 'B').
If element B is judged invalid, a bug occurs. Element A will have been
added to the currentElements array, but element B is what is added to
the errorList. So, when showErrors is called, element A will be in
validElements(), and will be unhighlighted.
This is fixed by having element() also change its target to be the
first element of the same name when passed a checkbox or radio input.
Signed-off-by: Eric Naeseth <eric@thumbtack.com>