summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJelle Sebreghts2013-03-23 09:07:21 (GMT)
committer Jelle Sebreghts2013-03-23 09:07:21 (GMT)
commitca7ecc405b48bb482f1177f9b0ac5ea02cdaf743 (patch)
treec713f18e575266bed2be331f8069bc0b853f507a
parente5b9eacbe09a3772c3092dffed781d52363559c9 (diff)
Add missing methods when in deprecated mode
-rw-r--r--clientside_validation.js24
-rw-r--r--clientside_validation.module1
2 files changed, 20 insertions, 5 deletions
diff --git a/clientside_validation.js b/clientside_validation.js
index 5dea3ec..539b693 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 1025733..c1f4b12 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();
}