Commit Graph

283 Commits

Author SHA1 Message Date
Nick Schonning
07779ae502 Additionals: Add postalCodeCA method
Checks for Canadian postal codes using the base regex from
http://geekswithblogs.net/MainaD/archive/2007/12/03/117321.aspx with
additional constraints from
http://www.canadapost.ca/tools/pg/manual/PGaddress-e.asp.

- First character must be a valid forward station character
- Must be all caps
- Must use space for forth character

Closes #1118
2014-05-20 16:05:32 +02:00
Markus Staab
d319a0da35 Core: Register focusin, focusout and keyup also on radio/checkbox
Fixes #1062
Closes #1065
2014-05-20 15:54:26 +02:00
Nick Schonning
f5a7ce5f98 All: Format HTML as per jQuery style guide
Fixes #1101
Closes #1104
2014-05-06 10:35:41 +02:00
Jörn Zaefferer
a0ed6f8111 Core: Fix normalization for rangelength attribute value
This regressed at some point, probably when rules-as-data-attributes where
introduced, since those are automatically parsed as JSON. For the unprocessed
attributes, the array brackets have to be removed.

Also fixes the milk demo, which specified rangelength as the message, instead of
minlength, which it actually uses.

Fixes #1087
2014-04-29 20:41:18 +02:00
Jamie R. Rytlewski
d09a5ee199 Core: Update elementValue method to deal with type="number" fields
The HTML5 draft defines, for type="number" inputs: "The value
sanitization algorithm is as follows: If the value of the element is not
a valid floating-point number, then set it to the empty string instead."
If the constraint validation considers the input invalid, return false
as the value, instead of the empty string, for the number and digit
methods to output their messages.

This would break in browsers that support type="number", but not the
constraint validation API. I don't know of any existing browser where
that applies.

Fixes #858
Fixes #922
Closes #1093
2014-04-29 20:23:43 +02:00
Markus Staab
104e8efceb Tests: Use asyncTest() method, replacing test() and stop() calls
Closes #1097
2014-04-29 17:56:41 +02:00
Jörn Zaefferer
e72a9b62df Test: Cleanup indent 2014-04-01 11:07:09 +02:00
Nic Jansma
9dc0d1dd94 Core: Allow attributes to have a value of zero (eg min='0')
Closes #1029
Closes #930
Fixes #854
2014-03-12 11:34:02 +01:00
Nick Schonning
3e09fcb719 JSHint: Apply onevar to tests 2014-01-23 18:14:23 -05:00
Nick Schonning
61f07e0fbc JSHint: Add back globals for browser and console 2014-01-23 17:46:11 -05:00
Nick Schonning
313fd1dd3f JSHint: Remove unused parameters
- Fix double quoting in mockjax response to use doublequotes again
2014-01-23 17:45:37 -05:00
Nick Schonning
3d6f596485 JSHint: Replace braces with dot notation 2014-01-23 16:23:10 -05:00
Nick Schonning
91fa266cfe JSHint: Replace single for double quotes in tests 2014-01-23 16:16:53 -05:00
Nick Schonning
d85bcb21a2 JSHint: Extract configuration to dotfiles 2014-01-23 15:19:30 -05:00
James Thompson
1a981b4403 Methods: Add additional method for currency
Closes gh-701
2014-01-14 19:22:06 +01:00
ruado1987
a86421131e Core: Ignore events on ignored elements
When an ignored element produces a blur event, it causes the valid() method to
return the wrong value.

Fixes gh-700
Closes gh-705
2014-01-14 17:54:51 +01:00
Martin Laine
5bebaa5c55 Core: Added support for generic messages via data-msg attribute
Closes gh-747
2014-01-14 17:34:38 +01:00
Jörn Zaefferer
279b932c12 Methods: Fix dateITA method, avoiding summertime errors
Using arbitrary hour or new Date() will use hour 00:00:00, which cause errors
on summertime changes.

Closes gh-773
2014-01-14 17:26:19 +01:00
Jamie R. Rytlewski
aa0d6241c3 Methods: Adding Smart Quotes to stripHTML's punctuation removal
Addresses an issue with the word count where smart quotes were not
removed, but the word count counted the words as the punctuation was not
removed.

Closes gh-811
2014-01-14 16:51:59 +01:00
Andrew Ray
f93e1deb48 Core: Trigger success on optional but have other successful validators
The comment in the code itself says "when there are no other rules" but does
nothing to enforce that comment.

Fixes gh-851
Closes gh-852
2014-01-14 16:36:29 +01:00
magic.xie
c1f0baf36c Core: Fix support for multiple error classes
String#replace with a string argument replaces just once, not all matches.

Closes gh-884
2014-01-14 16:21:27 +01:00
Bart Sipes
bf3b350914 Core: Disable deprecated $.format
Throwing error if $.format is called and updated all deprecated calls to use
$.validator.format.

Fixes gh-755
Closes gh-971
2014-01-14 15:45:21 +01:00
Jörn Zaefferer
d865e4c5b8 Methods: Fix tests for email method. Follow-up to dd162ae 2014-01-14 15:30:20 +01:00
Jörn Zaefferer
dd162ae360 Methods: Update email to use HTML5 regex, remove email2 method
The regex provided by the HTML5 spec allows email addresses without a top level
domain, like name@localhost. That makes the email2 method pointless.

Hopefully this is the last time the email methods ever has to be updated. At
least it will make bug triage easier: If you don't like the implementation,
report an issue against the HTML5 spec.

Fixes gh-828
Closes gh-753
Closes gh-739
2014-01-14 15:27:29 +01:00
Pat Heard
d7a05b1c26 Add qunit tests for conditional validation rules
Updated tests for require_from_group and skip_or_fill_minimum rules.
The tests now check that other validation rules on the form are
enforced.
2013-12-02 10:25:07 -05:00
Nick Schonning
bf3cfb234e Initial ARIA-Required implementation
Add aria-required tags to any of the data, static or class required elements.
Dynamic validation for rules added through the form.validate rules object do not get picked up till first run.
2013-10-07 17:51:08 +02:00
Nick Schonning
4f8a631cbe resetForm should clear any aria-invalid values 2013-10-07 17:51:08 +02:00
Nick Schonning
3d5658e9e4 Add ARIA testing
Added new test suite for testing the ARIA-invalid features
Also added a few minor fixes for typos in the QUnit scaffolding and
JSHint errors
Fix "%o has no name assigned [object HTMLInputElement]" errors in bypassValidation tests
2013-10-07 17:51:08 +02:00
Alfonso Martín
317c20fa9b Added NIF, NIE and CIF Spanish documents numbers validation
* Added some translations to /localization
* Added test suite
Fixes gh-830
2013-08-22 01:06:08 -04:00
Nick Schonning
519bbc656b phoneUS: Add N11 exclusions. Closes gh-861
Numbers like 911 and 411 cannot be used for area or exchange codes.
https://en.wikipedia.org/wiki/NANPA#Numbering_system
2013-08-21 10:33:26 +02:00
John Reilly
ae54bd54e1 Fix typo in date test. Closes gh-846 2013-08-15 13:46:25 +02:00
Andrew Ray
f5f47c5c66 Restricting credit card validator to include length check. Closes gh-772
Without this, '41111' is considered a valid credit card number.
2013-06-25 11:39:47 +02:00
Jörn Zaefferer
6f268031af valid(): Check all elements. Fixes #791 - valid() validates only the first (invalid) element 2013-06-24 14:59:22 +02:00
Nick Schonning
6480d26374 Fix paths in tests to use dist copy of files 2013-06-24 14:23:10 +02:00
g1smd
d447b41b83 Update phonesUK and mobileUK to accept new prefixes. Closes gh-750 2013-05-22 12:53:42 +02:00
Jörn Zaefferer
b51e86f558 Add extra unit test for zipcodeUS method, based on GH comment 2013-05-20 15:53:31 +02:00
rstaib
ed51405d84 Add validation method for BIC. Closes gh-743 2013-05-14 18:11:41 +02:00
Jörn Zaefferer
c7c621790a Update demos: Basic cleanup, no more metadata. Fixes #708 2013-05-12 16:44:33 +02:00
Strand McCutchen
165005d4b5 Verify nine-digit zip codes. Closes gh-726 2013-05-12 15:17:16 +02:00
Jörn Zaefferer
72f179f1c9 Update demos and tests to jQuery 1.9.1 2013-05-12 15:03:43 +02:00
Veres Lajos
f79e647f9f typo fixes 2013-05-08 14:35:26 +01:00
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
Bogdan Litescu
4a134b6db6 Fixed 'messages' coming up as a rule and causing an exception after being updated through rules("add"). Closes gh-670, fixes #624 2013-03-20 12:49:25 +01:00
James Thompson
bbbf87903d Improved the UK postcode method to filter out more invalid postcodes. Closes #682
Old one allows integers between 5-7 digits which is not valid.

New one is still case insensitive and allows spaces & fixes the above issue.
2013-03-20 12:19:20 +01:00
Nick Schonning
58ee5e219c Update QUnit to 1.11 2013-03-19 23:15:35 -04:00
jzaefferer
4a51e71c6f Fix typos 2013-03-07 13:55:35 +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
Robbert Wethmar
509e6e3619 Add additional, dutch-specific methods: phone, mobile, postal, bank and giro account
add dutch phone number validation
2013-02-27 15:43:06 +01:00
Robbert Wethmar
581ccd80ec Added iban validation. Closes gh-630 2013-02-27 14:27:22 +01:00
Jörn Zaefferer
58dece930a Add tests for phoneUK method 2013-02-27 14:07:05 +01:00