Commit Graph

39 Commits

Author SHA1 Message Date
Erik van Konijnenburg
5b114e10db Fix min/max validation. Closes gh-666. Fixes #648
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.
2013-03-20 13:17:58 +01:00
Jörn Zaefferer
93bab6e916 Make valid() return a boolean instead of 0 or 1. Fixes #109 - valid() does not return boolean value 2013-02-28 16:17:43 +01:00
Paul Cichonski
bcff73ad84 Bypass validation for buttons with 'formnovalidate' attribute (same as class="cancel"). Closes gh-623 2013-02-12 13:38:47 +01:00
Alexander I. Zaytsev
69831a08cf Remove clearing as numbers of min, max and range rules. Fixes #455. Closes gh-528.
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.
2013-02-04 12:11:10 +01:00
Nick Williams
856cec06b8 Update pre-existing labels - fixes #430 closes gh-436
made assumption that any existing label which already has errorClass is
safe to update with a new message.
2013-01-31 12:55:17 +01:00
Jörn Zaefferer
b5cd04e327 Lint test files 2013-01-31 00:28:13 +01:00
Jörn Zaefferer
2b1b2563c5 Fix $.validator.format to avoid group interpolation, where at least IE8/9 replaces -bash with the match. Fixes #614 2013-01-31 00:12:32 +01:00
John-Philip Johansson
0681cc06c5 Added jQuery 1.9 to the project. Closes gh-613 2013-01-30 23:14:20 +01:00
IamDavidovich
b82d8cc1db Allow groups to be an array or a string - Fixes #479
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.
2012-12-10 12:59:37 +01:00
Synchro
e4f3a87493 Fix some date validations, JS syntax errors. 2012-11-26 11:48:24 +01:00
Max Lynch
6df33a8ccc Remove support for metadata plugin, replace with data-rule- and data-msg- (added in 907467e8) properties. 2012-11-23 14:39:37 +01:00
Jörn Zaefferer
5ec962ebb6 Update dependencies: Remove old jQuery versions, include new ones. Update QUnit and Form plugin. 2012-11-23 14:26:56 +01:00
Max Lynch
907467e874 Merged in changes for specifying custom error messages in data attributes 2012-05-15 17:39:40 -05:00
Max Lynch
a8568232a6 Add element to success call with test. Fixes #60 2012-05-07 11:30:10 +02:00
Max Lynch
f0b8042233 resetForm now clears old previousValue on form elements. Fixes #312 2012-05-04 10:48:49 -05:00
Max Lynch
aca144b5eb Disables blur event when onfocusout is set to false. Test added. 2012-04-20 15:11:34 +02:00
Max Lynch
58930870c6 Fixed value issue for radio buttons and checkboxes. Fixes #363 2012-04-20 15:09:15 +02:00
Max Lynch
a436634fe8 Added pseudo selector for text input types to fix issue with default empty type attribute. Added tests and some test markup. Fixes #217 2012-04-18 00:14:33 +02:00
Jörn Zaefferer
ba717554b1 Update to QUnit 1.5.0 2012-04-04 19:14:31 +02:00
Max Lynch
1bbf7a636f Support for dynamically added submit buttons, and updated test case. Uses validateDelegate. Code from PR #9 2012-04-02 14:55:56 +02:00
Başar Aykut
bafc78671a Fixed handling of multiple class names for errorClass option. Test by Max Lynch. Fixes #280 2012-03-29 19:20:50 +02:00
Jörn Zaefferer
c243e8ee88 Update testsuite to use equal and deepEqual. Fix tests that the fix for #219 (732f5ff04b) broke. The element method now returns true for dependency-mismatch, that's fine. 2012-02-24 17:58:46 +01:00
Horia Dragomir
2170712966 Fixed #189 - :hidden elements are now ignored by default 2011-09-15 14:23:10 +02:00
Jörn Zaefferer
665f67df4f Cleanup whitespace 2011-09-13 15:51:28 +02:00
Eric Naeseth
f2321e1f9f Fixed #177 - Fix validation of a single radio or checkbox input
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>
2011-09-13 15:50:08 +02:00
Haacked
393ccabc07 Fixed issue 78. Error/Valid styling applies to all radio buttons of same group for required validation. 2011-05-05 13:34:23 +02:00
jzaefferer
bb4a84a184 Mock ajax requests to replace .php files (make testsuite run on
gh-pages). Also clean up unnecessary tests for .php files, had several
bugs anyway.
2011-04-24 20:08:55 +02:00
jzaefferer
bd70d9a4f8 Disable QUnit reordering and fix a custom events related issue in test. 2011-02-26 22:06:58 +01:00
jzaefferer
858ca34cf4 Fix elements ordering test. 2011-01-29 12:02:07 +01:00
jzaefferer
10d0d9b15f Fixed the broken testsuite, with an update to current QUnit. A few tests still broken. 2011-01-28 17:15:32 +01:00
jzaefferer
1b464f32b3 Tests and fix for focusCleanup with wrapper 2010-07-14 18:23:08 +02:00
jzaefferer
c466947ebe Tests for focusCleanup option 2010-07-14 18:07:10 +02:00
jzaefferer
5bb2441f04 CRLF conversions 2010-05-05 15:52:04 +02:00
Jörn Zaeffferer
7851551103 Bugfixes for compability with jQuery 1.4.2, while maintaining backwards-compability 2010-03-09 19:38:36 +00:00
Jörn Zaeffferer
7c47463a58 Testsuite bugfixes for compability with jQuery 1.4.2, while maintaining backwards-compability 2010-03-09 18:11:03 +00:00
Jörn Zaeffferer
6ba056b138 Bugfixes for compability with jQuery 1.4.2, while maintaining backwards-compability 2010-03-08 23:31:24 +00:00
Jörn Zaeffferer
ce09691a35 * Added automatic detection of substitution parameters in messages, removing the need to provide format functions (http://plugins.jquery.com/node/11195) 2009-11-30 18:25:47 +00:00
Jörn Zaeffferer
acb5c9226c validate: * Fixed two accidental global variables 2009-09-15 08:07:06 +00:00
Jörn Zaeffferer
ce7c5baa4e 2009-08-01 11:54:55 +00:00