mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2025-12-20 09:11:40 +01:00
JSHint: Replace single for double quotes in src
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Accept a value from a file input based on a required mimetype
|
||||
jQuery.validator.addMethod("accept", function(value, element, param) {
|
||||
// Split mime on commas in case we have multiple types we can accept
|
||||
var typeParam = typeof param === "string" ? param.replace(/\s/g, '').replace(/,/g, '|') : "image/*",
|
||||
var typeParam = typeof param === "string" ? param.replace(/\s/g, "").replace(/,/g, "|") : "image/*",
|
||||
optionalValue = this.optional(element),
|
||||
i, file;
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
|
||||
function stripHtml(value) {
|
||||
// remove html tags and space chars
|
||||
return value.replace(/<.[^<>]*?>/g, ' ').replace(/ | /gi, ' ')
|
||||
return value.replace(/<.[^<>]*?>/g, " ").replace(/ | /gi, " ")
|
||||
// remove punctuation
|
||||
.replace(/[.(),;:!?%#$'"_+=\/\-“”’]*/g,'');
|
||||
.replace(/[.(),;:!?%#$'\"_+=\/\-“”’]*/g, "");
|
||||
}
|
||||
|
||||
jQuery.validator.addMethod("maxWords", function(value, element, params) {
|
||||
|
||||
@@ -12,7 +12,7 @@ jQuery.validator.addMethod("bankaccountNL", function(value, element) {
|
||||
return false;
|
||||
}
|
||||
// now '11 check'
|
||||
var account = value.replace(/ /g,''), // remove spaces
|
||||
var account = value.replace(/ /g, ""), // remove spaces
|
||||
sum = 0,
|
||||
len = account.length,
|
||||
pos, factor, digit;
|
||||
|
||||
@@ -12,7 +12,7 @@ jQuery.validator.addMethod( "cifES", function( value, element ) {
|
||||
value = value.toUpperCase();
|
||||
|
||||
// Quick format test
|
||||
if ( !value.match( '((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)' ) ) {
|
||||
if ( !value.match( "((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)" ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ jQuery.validator.addMethod( "cifES", function( value, element ) {
|
||||
var tmp = ( 2 * num[ count ] ).toString(),
|
||||
secondDigit = tmp.charAt( 1 );
|
||||
|
||||
sum += parseInt( tmp.charAt( 0 ), 10 ) + ( secondDigit === '' ? 0 : parseInt( secondDigit, 10 ) );
|
||||
sum += parseInt( tmp.charAt( 0 ), 10 ) + ( secondDigit === "" ? 0 : parseInt( secondDigit, 10 ) );
|
||||
}
|
||||
|
||||
/* The first (position 1) is a letter following the following criteria:
|
||||
@@ -51,7 +51,7 @@ jQuery.validator.addMethod( "cifES", function( value, element ) {
|
||||
* W. Permanent establishments of non-resident in Spain
|
||||
*/
|
||||
if ( /^[ABCDEFGHJNPQRSUVW]{1}/.test( value ) ) {
|
||||
sum += '';
|
||||
sum += "";
|
||||
controlDigit = 10 - parseInt( sum.charAt( sum.length - 1 ), 10 );
|
||||
value += controlDigit;
|
||||
return ( num[ 8 ].toString() === String.fromCharCode( 64 + controlDigit ) || num[ 8 ].toString() === value.charAt( value.length - 1 ) );
|
||||
|
||||
@@ -3,39 +3,39 @@
|
||||
* Symbols can be optional or required. Symbols required by default
|
||||
*
|
||||
* Usage examples:
|
||||
* currency: ['£', false] - Use false for soft currency validation
|
||||
* currency: ['$', false]
|
||||
* currency: ['RM', false] - also works with text based symbols such as 'RM' - Malaysia Ringgit etc
|
||||
* currency: ["£", false] - Use false for soft currency validation
|
||||
* currency: ["$", false]
|
||||
* currency: ["RM", false] - also works with text based symbols such as "RM" - Malaysia Ringgit etc
|
||||
*
|
||||
* <input class="currencyInput" name="currencyInput">
|
||||
*
|
||||
* Soft symbol checking
|
||||
* currencyInput: {
|
||||
* currency: ['$', false]
|
||||
* currency: ["$", false]
|
||||
* }
|
||||
*
|
||||
* Strict symbol checking (default)
|
||||
* currencyInput: {
|
||||
* currency: '$'
|
||||
* currency: "$"
|
||||
* //OR
|
||||
* currency: ['$', true]
|
||||
* currency: ["$", true]
|
||||
* }
|
||||
*
|
||||
* Multiple Symbols
|
||||
* currencyInput: {
|
||||
* currency: '$,£,¢'
|
||||
* currency: "$,£,¢"
|
||||
* }
|
||||
*/
|
||||
jQuery.validator.addMethod('currency', function(value, element, param) {
|
||||
var paramType = typeof param === 'string',
|
||||
jQuery.validator.addMethod("currency", function(value, element, param) {
|
||||
var paramType = typeof param === "string",
|
||||
symbol = paramType ? param : param[0],
|
||||
soft = paramType ? true : param[1],
|
||||
regex;
|
||||
|
||||
symbol = symbol.replace(/,/g, '');
|
||||
symbol = soft ? symbol + ']' : symbol + ']?';
|
||||
regex = '^[' + symbol + '([1-9]{1}[0-9]{0,2}(\\,[0-9]{3})*(\\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\\.[0-9]{0,2})?|0(\\.[0-9]{0,2})?|(\\.[0-9]{1,2})?)$';
|
||||
symbol = symbol.replace(/,/g, "");
|
||||
symbol = soft ? symbol + "]" : symbol + "]?";
|
||||
regex = "^[" + symbol + "([1-9]{1}[0-9]{0,2}(\\,[0-9]{3})*(\\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\\.[0-9]{0,2})?|0(\\.[0-9]{0,2})?|(\\.[0-9]{1,2})?)$";
|
||||
regex = new RegExp(regex);
|
||||
return this.optional(element) || regex.test(value);
|
||||
|
||||
}, 'Please specify a valid currency');
|
||||
}, "Please specify a valid currency");
|
||||
|
||||
@@ -22,7 +22,7 @@ jQuery.validator.addMethod("dateITA", function(value, element) {
|
||||
re = /^\d{1,2}\/\d{1,2}\/\d{4}$/,
|
||||
adata, gg, mm, aaaa, xdata;
|
||||
if ( re.test(value)) {
|
||||
adata = value.split('/');
|
||||
adata = value.split("/");
|
||||
gg = parseInt(adata[0],10);
|
||||
mm = parseInt(adata[1],10);
|
||||
aaaa = parseInt(adata[2],10);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Older "accept" file extension method. Old docs: http://docs.jquery.com/Plugins/Validation/Methods/accept
|
||||
jQuery.validator.addMethod("extension", function(value, element, param) {
|
||||
param = typeof param === "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
|
||||
param = typeof param === "string" ? param.replace(/,/g, "|") : "png|jpe?g|gif";
|
||||
return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
|
||||
}, jQuery.validator.format("Please enter a value with a valid extension."));
|
||||
|
||||
@@ -9,11 +9,11 @@ jQuery.validator.addMethod("iban", function(value, element) {
|
||||
}
|
||||
|
||||
// remove spaces and to upper case
|
||||
var iban = value.replace(/ /g,'').toUpperCase(),
|
||||
var iban = value.replace(/ /g,"").toUpperCase(),
|
||||
ibancheckdigits = "",
|
||||
leadingZeroes = true,
|
||||
cRest = '',
|
||||
cOperator = '',
|
||||
cRest = "",
|
||||
cOperator = "",
|
||||
countrycode, ibancheck, charAt, cChar, bbanpattern, bbancountrypatterns, ibanregexp, i, p;
|
||||
|
||||
if (!(/^([a-zA-Z0-9]{4} ){2,8}[a-zA-Z0-9]{1,4}|[a-zA-Z0-9]{12,34}$/.test(iban))) {
|
||||
@@ -23,70 +23,70 @@ jQuery.validator.addMethod("iban", function(value, element) {
|
||||
// check the country code and find the country specific format
|
||||
countrycode = iban.substring(0,2);
|
||||
bbancountrypatterns = {
|
||||
'AL': "\\d{8}[\\dA-Z]{16}",
|
||||
'AD': "\\d{8}[\\dA-Z]{12}",
|
||||
'AT': "\\d{16}",
|
||||
'AZ': "[\\dA-Z]{4}\\d{20}",
|
||||
'BE': "\\d{12}",
|
||||
'BH': "[A-Z]{4}[\\dA-Z]{14}",
|
||||
'BA': "\\d{16}",
|
||||
'BR': "\\d{23}[A-Z][\\dA-Z]",
|
||||
'BG': "[A-Z]{4}\\d{6}[\\dA-Z]{8}",
|
||||
'CR': "\\d{17}",
|
||||
'HR': "\\d{17}",
|
||||
'CY': "\\d{8}[\\dA-Z]{16}",
|
||||
'CZ': "\\d{20}",
|
||||
'DK': "\\d{14}",
|
||||
'DO': "[A-Z]{4}\\d{20}",
|
||||
'EE': "\\d{16}",
|
||||
'FO': "\\d{14}",
|
||||
'FI': "\\d{14}",
|
||||
'FR': "\\d{10}[\\dA-Z]{11}\\d{2}",
|
||||
'GE': "[\\dA-Z]{2}\\d{16}",
|
||||
'DE': "\\d{18}",
|
||||
'GI': "[A-Z]{4}[\\dA-Z]{15}",
|
||||
'GR': "\\d{7}[\\dA-Z]{16}",
|
||||
'GL': "\\d{14}",
|
||||
'GT': "[\\dA-Z]{4}[\\dA-Z]{20}",
|
||||
'HU': "\\d{24}",
|
||||
'IS': "\\d{22}",
|
||||
'IE': "[\\dA-Z]{4}\\d{14}",
|
||||
'IL': "\\d{19}",
|
||||
'IT': "[A-Z]\\d{10}[\\dA-Z]{12}",
|
||||
'KZ': "\\d{3}[\\dA-Z]{13}",
|
||||
'KW': "[A-Z]{4}[\\dA-Z]{22}",
|
||||
'LV': "[A-Z]{4}[\\dA-Z]{13}",
|
||||
'LB': "\\d{4}[\\dA-Z]{20}",
|
||||
'LI': "\\d{5}[\\dA-Z]{12}",
|
||||
'LT': "\\d{16}",
|
||||
'LU': "\\d{3}[\\dA-Z]{13}",
|
||||
'MK': "\\d{3}[\\dA-Z]{10}\\d{2}",
|
||||
'MT': "[A-Z]{4}\\d{5}[\\dA-Z]{18}",
|
||||
'MR': "\\d{23}",
|
||||
'MU': "[A-Z]{4}\\d{19}[A-Z]{3}",
|
||||
'MC': "\\d{10}[\\dA-Z]{11}\\d{2}",
|
||||
'MD': "[\\dA-Z]{2}\\d{18}",
|
||||
'ME': "\\d{18}",
|
||||
'NL': "[A-Z]{4}\\d{10}",
|
||||
'NO': "\\d{11}",
|
||||
'PK': "[\\dA-Z]{4}\\d{16}",
|
||||
'PS': "[\\dA-Z]{4}\\d{21}",
|
||||
'PL': "\\d{24}",
|
||||
'PT': "\\d{21}",
|
||||
'RO': "[A-Z]{4}[\\dA-Z]{16}",
|
||||
'SM': "[A-Z]\\d{10}[\\dA-Z]{12}",
|
||||
'SA': "\\d{2}[\\dA-Z]{18}",
|
||||
'RS': "\\d{18}",
|
||||
'SK': "\\d{20}",
|
||||
'SI': "\\d{15}",
|
||||
'ES': "\\d{20}",
|
||||
'SE': "\\d{20}",
|
||||
'CH': "\\d{5}[\\dA-Z]{12}",
|
||||
'TN': "\\d{20}",
|
||||
'TR': "\\d{5}[\\dA-Z]{17}",
|
||||
'AE': "\\d{3}\\d{16}",
|
||||
'GB': "[A-Z]{4}\\d{14}",
|
||||
'VG': "[\\dA-Z]{4}\\d{16}"
|
||||
"AL": "\\d{8}[\\dA-Z]{16}",
|
||||
"AD": "\\d{8}[\\dA-Z]{12}",
|
||||
"AT": "\\d{16}",
|
||||
"AZ": "[\\dA-Z]{4}\\d{20}",
|
||||
"BE": "\\d{12}",
|
||||
"BH": "[A-Z]{4}[\\dA-Z]{14}",
|
||||
"BA": "\\d{16}",
|
||||
"BR": "\\d{23}[A-Z][\\dA-Z]",
|
||||
"BG": "[A-Z]{4}\\d{6}[\\dA-Z]{8}",
|
||||
"CR": "\\d{17}",
|
||||
"HR": "\\d{17}",
|
||||
"CY": "\\d{8}[\\dA-Z]{16}",
|
||||
"CZ": "\\d{20}",
|
||||
"DK": "\\d{14}",
|
||||
"DO": "[A-Z]{4}\\d{20}",
|
||||
"EE": "\\d{16}",
|
||||
"FO": "\\d{14}",
|
||||
"FI": "\\d{14}",
|
||||
"FR": "\\d{10}[\\dA-Z]{11}\\d{2}",
|
||||
"GE": "[\\dA-Z]{2}\\d{16}",
|
||||
"DE": "\\d{18}",
|
||||
"GI": "[A-Z]{4}[\\dA-Z]{15}",
|
||||
"GR": "\\d{7}[\\dA-Z]{16}",
|
||||
"GL": "\\d{14}",
|
||||
"GT": "[\\dA-Z]{4}[\\dA-Z]{20}",
|
||||
"HU": "\\d{24}",
|
||||
"IS": "\\d{22}",
|
||||
"IE": "[\\dA-Z]{4}\\d{14}",
|
||||
"IL": "\\d{19}",
|
||||
"IT": "[A-Z]\\d{10}[\\dA-Z]{12}",
|
||||
"KZ": "\\d{3}[\\dA-Z]{13}",
|
||||
"KW": "[A-Z]{4}[\\dA-Z]{22}",
|
||||
"LV": "[A-Z]{4}[\\dA-Z]{13}",
|
||||
"LB": "\\d{4}[\\dA-Z]{20}",
|
||||
"LI": "\\d{5}[\\dA-Z]{12}",
|
||||
"LT": "\\d{16}",
|
||||
"LU": "\\d{3}[\\dA-Z]{13}",
|
||||
"MK": "\\d{3}[\\dA-Z]{10}\\d{2}",
|
||||
"MT": "[A-Z]{4}\\d{5}[\\dA-Z]{18}",
|
||||
"MR": "\\d{23}",
|
||||
"MU": "[A-Z]{4}\\d{19}[A-Z]{3}",
|
||||
"MC": "\\d{10}[\\dA-Z]{11}\\d{2}",
|
||||
"MD": "[\\dA-Z]{2}\\d{18}",
|
||||
"ME": "\\d{18}",
|
||||
"NL": "[A-Z]{4}\\d{10}",
|
||||
"NO": "\\d{11}",
|
||||
"PK": "[\\dA-Z]{4}\\d{16}",
|
||||
"PS": "[\\dA-Z]{4}\\d{21}",
|
||||
"PL": "\\d{24}",
|
||||
"PT": "\\d{21}",
|
||||
"RO": "[A-Z]{4}[\\dA-Z]{16}",
|
||||
"SM": "[A-Z]\\d{10}[\\dA-Z]{12}",
|
||||
"SA": "\\d{2}[\\dA-Z]{18}",
|
||||
"RS": "\\d{18}",
|
||||
"SK": "\\d{20}",
|
||||
"SI": "\\d{15}",
|
||||
"ES": "\\d{20}",
|
||||
"SE": "\\d{20}",
|
||||
"CH": "\\d{5}[\\dA-Z]{12}",
|
||||
"TN": "\\d{20}",
|
||||
"TR": "\\d{5}[\\dA-Z]{17}",
|
||||
"AE": "\\d{3}\\d{16}",
|
||||
"GB": "[A-Z]{4}\\d{14}",
|
||||
"VG": "[\\dA-Z]{4}\\d{16}"
|
||||
};
|
||||
|
||||
bbanpattern = bbancountrypatterns[countrycode];
|
||||
@@ -97,7 +97,7 @@ jQuery.validator.addMethod("iban", function(value, element) {
|
||||
// by the checksum validation below anyway.
|
||||
// Strict checking should return FALSE for unknown
|
||||
// countries.
|
||||
if (typeof bbanpattern !== 'undefined') {
|
||||
if (typeof bbanpattern !== "undefined") {
|
||||
ibanregexp = new RegExp("^[A-Z]{2}\\d{2}" + bbanpattern + "$", "");
|
||||
if (!(ibanregexp.test(iban))) {
|
||||
return false; // invalid country specific format
|
||||
@@ -119,7 +119,7 @@ jQuery.validator.addMethod("iban", function(value, element) {
|
||||
// calculate the result of: ibancheckdigits % 97
|
||||
for (p = 0; p < ibancheckdigits.length; p++) {
|
||||
cChar = ibancheckdigits.charAt(p);
|
||||
cOperator = '' + cRest + '' + cChar;
|
||||
cOperator = "" + cRest + "" + cChar;
|
||||
cRest = cOperator % 97;
|
||||
}
|
||||
return cRest === 1;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
* A number of very detailed GB telephone number RegEx patterns can also be found at:
|
||||
* http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers
|
||||
*/
|
||||
jQuery.validator.addMethod('mobileUK', function(phone_number, element) {
|
||||
phone_number = phone_number.replace(/\(|\)|\s+|-/g,'');
|
||||
jQuery.validator.addMethod("mobileUK", function(phone_number, element) {
|
||||
phone_number = phone_number.replace(/\(|\)|\s+|-/g, "");
|
||||
return this.optional(element) || phone_number.length > 9 &&
|
||||
phone_number.match(/^(?:(?:(?:00\s?|\+)44\s?|0)7(?:[1345789]\d{2}|624)\s?\d{3}\s?\d{3})$/);
|
||||
}, 'Please specify a valid mobile number');
|
||||
}, "Please specify a valid mobile number");
|
||||
|
||||
@@ -7,7 +7,7 @@ jQuery.validator.addMethod( "nieES", function( value, element ) {
|
||||
value = value.toUpperCase();
|
||||
|
||||
// Basic format test
|
||||
if ( !value.match( '((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)' ) ) {
|
||||
if ( !value.match( "((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)" ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ jQuery.validator.addMethod( "nieES", function( value, element ) {
|
||||
if ( /^[XYZ]{1}/.test( value ) ) {
|
||||
return (
|
||||
value[ 8 ] === "TRWAGMYFPDXBNJZSQVHLCKE".charAt(
|
||||
value.replace( 'X', '0' )
|
||||
.replace( 'Y', '1' )
|
||||
.replace( 'Z', '2' )
|
||||
value.replace( "X", "0" )
|
||||
.replace( "Y", "1" )
|
||||
.replace( "Z", "2" )
|
||||
.substring( 0, 8 ) % 23
|
||||
)
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@ jQuery.validator.addMethod( "nifES", function( value, element ) {
|
||||
value = value.toUpperCase();
|
||||
|
||||
// Basic format test
|
||||
if ( !value.match('((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)') ) {
|
||||
if ( !value.match("((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)") ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ jQuery.validator.addMethod("pattern", function(value, element, param) {
|
||||
if (this.optional(element)) {
|
||||
return true;
|
||||
}
|
||||
if (typeof param === 'string') {
|
||||
if (typeof param === "string") {
|
||||
param = new RegExp(param);
|
||||
}
|
||||
return param.test(value);
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
* A number of very detailed GB telephone number RegEx patterns can also be found at:
|
||||
* http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers
|
||||
*/
|
||||
jQuery.validator.addMethod('phoneUK', function(phone_number, element) {
|
||||
phone_number = phone_number.replace(/\(|\)|\s+|-/g,'');
|
||||
jQuery.validator.addMethod("phoneUK", function(phone_number, element) {
|
||||
phone_number = phone_number.replace(/\(|\)|\s+|-/g, "");
|
||||
return this.optional(element) || phone_number.length > 9 &&
|
||||
phone_number.match(/^(?:(?:(?:00\s?|\+)44\s?)|(?:\(?0))(?:\d{2}\)?\s?\d{4}\s?\d{4}|\d{3}\)?\s?\d{3}\s?\d{3,4}|\d{4}\)?\s?(?:\d{5}|\d{3}\s?\d{3})|\d{5}\)?\s?\d{4,5})$/);
|
||||
}, 'Please specify a valid phone number');
|
||||
}, "Please specify a valid phone number");
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
* http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers
|
||||
*/
|
||||
//Matches UK landline + mobile, accepting only 01-3 for landline or 07 for mobile to exclude many premium numbers
|
||||
jQuery.validator.addMethod('phonesUK', function(phone_number, element) {
|
||||
phone_number = phone_number.replace(/\(|\)|\s+|-/g,'');
|
||||
jQuery.validator.addMethod("phonesUK", function(phone_number, element) {
|
||||
phone_number = phone_number.replace(/\(|\)|\s+|-/g, "");
|
||||
return this.optional(element) || phone_number.length > 9 &&
|
||||
phone_number.match(/^(?:(?:(?:00\s?|\+)44\s?|0)(?:1\d{8,9}|[23]\d{9}|7(?:[1345789]\d{8}|624\d{6})))$/);
|
||||
}, 'Please specify a valid uk phone number');
|
||||
}, "Please specify a valid uk phone number");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Matches UK postcode. Does not match to UK Channel Islands that have their own postcodes (non standard UK)
|
||||
jQuery.validator.addMethod('postcodeUK', function(value, element) {
|
||||
jQuery.validator.addMethod("postcodeUK", function(value, element) {
|
||||
return this.optional(element) || /^((([A-PR-UWYZ][0-9])|([A-PR-UWYZ][0-9][0-9])|([A-PR-UWYZ][A-HK-Y][0-9])|([A-PR-UWYZ][A-HK-Y][0-9][0-9])|([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))\s?([0-9][ABD-HJLNP-UW-Z]{2})|(GIR)\s?(0AA))$/i.test(value);
|
||||
}, 'Please specify a valid UK postcode');
|
||||
}, "Please specify a valid UK postcode");
|
||||
|
||||
@@ -17,21 +17,21 @@
|
||||
jQuery.validator.addMethod("require_from_group", function(value, element, options) {
|
||||
var $fields = $(options[1], element.form),
|
||||
$fieldsFirst = $fields.eq(0),
|
||||
validator = $fieldsFirst.data('valid_req_grp') ? $fieldsFirst.data('valid_req_grp') : $.extend({}, this),
|
||||
validator = $fieldsFirst.data("valid_req_grp") ? $fieldsFirst.data("valid_req_grp") : $.extend({}, this),
|
||||
isValid = $fields.filter(function() {
|
||||
return validator.elementValue(this);
|
||||
}).length >= options[0];
|
||||
|
||||
// Store the cloned validator for future validation
|
||||
$fieldsFirst.data('valid_req_grp', validator);
|
||||
$fieldsFirst.data("valid_req_grp", validator);
|
||||
|
||||
// If element isn't being validated, run each require_from_group field's validation rules
|
||||
if (!$(element).data('being_validated')) {
|
||||
$fields.data('being_validated', true);
|
||||
if (!$(element).data("being_validated")) {
|
||||
$fields.data("being_validated", true);
|
||||
$fields.each(function() {
|
||||
validator.element(this);
|
||||
});
|
||||
$fields.data('being_validated', false);
|
||||
$fields.data("being_validated", false);
|
||||
}
|
||||
return isValid;
|
||||
}, jQuery.validator.format("Please fill at least {0} of these fields."));
|
||||
|
||||
@@ -22,22 +22,22 @@
|
||||
jQuery.validator.addMethod("skip_or_fill_minimum", function(value, element, options) {
|
||||
var $fields = $(options[1], element.form),
|
||||
$fieldsFirst = $fields.eq(0),
|
||||
validator = $fieldsFirst.data('valid_skip') ? $fieldsFirst.data('valid_skip') : $.extend({}, this),
|
||||
validator = $fieldsFirst.data("valid_skip") ? $fieldsFirst.data("valid_skip") : $.extend({}, this),
|
||||
numberFilled = $fields.filter(function() {
|
||||
return validator.elementValue(this);
|
||||
}).length,
|
||||
isValid = numberFilled === 0 || numberFilled >= options[0];
|
||||
|
||||
// Store the cloned validator for future validation
|
||||
$fieldsFirst.data('valid_skip', validator);
|
||||
$fieldsFirst.data("valid_skip", validator);
|
||||
|
||||
// If element isn't being validated, run each skip_or_fill_minimum field's validation rules
|
||||
if (!$(element).data('being_validated')) {
|
||||
$fields.data('being_validated', true);
|
||||
if (!$(element).data("being_validated")) {
|
||||
$fields.data("being_validated", true);
|
||||
$fields.each(function() {
|
||||
validator.element(this);
|
||||
});
|
||||
$fields.data('being_validated', false);
|
||||
$fields.data("being_validated", false);
|
||||
}
|
||||
return isValid;
|
||||
}, jQuery.validator.format("Please either skip these fields or fill at least {0} of them."));
|
||||
|
||||
@@ -531,7 +531,7 @@ $.extend($.validator, {
|
||||
},
|
||||
|
||||
errors: function() {
|
||||
var errorClass = this.settings.errorClass.split(" ").join('.');
|
||||
var errorClass = this.settings.errorClass.split(" ").join(".");
|
||||
return $(this.settings.errorElement + "." + errorClass, this.errorContext);
|
||||
},
|
||||
|
||||
@@ -907,7 +907,7 @@ $.extend($.validator, {
|
||||
|
||||
if ( value ) {
|
||||
rules[method] = value;
|
||||
} else if ( type === method && type !== 'range' ) {
|
||||
} else if ( type === method && type !== "range" ) {
|
||||
// exception: the jquery validate 'range' method
|
||||
// does not test for the html5 'range' type
|
||||
rules[method] = true;
|
||||
@@ -976,12 +976,12 @@ $.extend($.validator, {
|
||||
});
|
||||
|
||||
// clean number parameters
|
||||
$.each([ 'minlength', 'maxlength' ], function() {
|
||||
$.each([ "minlength", "maxlength" ], function() {
|
||||
if ( rules[this] ) {
|
||||
rules[this] = Number(rules[this]);
|
||||
}
|
||||
});
|
||||
$.each([ 'rangelength', 'range' ], function() {
|
||||
$.each([ "rangelength", "range" ], function() {
|
||||
var parts;
|
||||
if ( rules[this] ) {
|
||||
if ( $.isArray(rules[this]) ) {
|
||||
|
||||
Reference in New Issue
Block a user