diff --git a/clientside_validation.js b/clientside_validation.js index 5dea3ec3181633c0ae63478c8d25e0e9183912f2..539b6930fddbb3ef2f8db452b8f0bb111204514f 100644 --- a/clientside_validation.js +++ b/clientside_validation.js @@ -825,11 +825,6 @@ return (amountChecked >= param[0] && amountChecked <= param[1]); }, jQuery.format('Minimum {0}, maximum {1}')); - // Allow integers, same as digits but including a leading '-' - jQuery.validator.addMethod("digits_negative", function(value, element) { - return this.optional(element) || /^-?\d+$/.test(value); - }, jQuery.format('Please enter only digits.')); - // One of the values jQuery.validator.addMethod("oneOf", function(value, element, param) { for (var p in param.values) { @@ -1310,6 +1305,25 @@ } }, jQuery.format('Not a valid EAN number.')); + if (Drupal.settings.clientsideValidation.deprecated) { + jQuery.validator.addMethod("rangeWords", function(value, element, param) { + return this.optional(element) || (param[0] <= jQuery.trim(value).split(/\s+/).length && value.split(/\s+/).length <= param[1]); + }, jQuery.format('The value must be between {0} and {1} words long')); + + jQuery.validator.addMethod("minWords", function(value, element, param) { + return this.optional(element) || param <= jQuery.trim(value).split(/\s+/).length; + }, jQuery.format('The value must be more than {0} words long')); + + jQuery.validator.addMethod("maxWords", function(value, element, param) { + return this.optional(element) || jQuery.trim(value).split(/\s+/).length <= param; + }, jQuery.format('The value must be fewer than {0} words long')); + + // Allow integers, same as digits but including a leading '-' + jQuery.validator.addMethod("integer", function(value, element) { + return this.optional(element) || /^-?\d+$/.test(value); + }, jQuery.format('Please enter only digits.')); + } + /** * Allow other modules to add more rules. * @event clientsideValidationAddCustomRules diff --git a/clientside_validation.module b/clientside_validation.module index 1025733512f27535f0342e24faa9fd203ac35cce..c1f4b12006f3a43eb43228a915486c391d884fce 100644 --- a/clientside_validation.module +++ b/clientside_validation.module @@ -419,6 +419,7 @@ function clientside_validation_add_js_settings($settings) { } else { // @todo: deprecated. + $settings['clientsideValidation']['deprecated'] = TRUE; _clientside_validation_add_js_deprecated(); }