diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..dfc6e63 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,40 @@ +module.exports = function( grunt ) { + +grunt.loadNpmTasks( "grunt-jquery-content" ); + +grunt.initConfig({ + xmllint: { + all: [ + "entries/**", + "categories.xml", + "entries2html.xsl", + "notes.xsl" + ] + }, + "build-posts": { + page: "pages/**" + }, + "build-xml-entries": { + all: "entries/**" + }, + "build-resources": { + all: "resources/**" + }, + wordpress: (function() { + var config = require( "./config" ); + config.dir = "dist/wordpress"; + return config; + })() +}); + +grunt.registerTask( "lint", [ "xmllint" ] ); + +grunt.registerTask( "build", [ + "build-posts", + "build-resources", + "build-xml-entries", + "build-xml-categories", + "build-xml-full" +]); + +}; diff --git a/LICENSE-MIT.txt b/LICENSE-MIT.txt index 8f3d8cf..61daee1 100644 --- a/LICENSE-MIT.txt +++ b/LICENSE-MIT.txt @@ -2,7 +2,7 @@ Copyright (c) 2013 Jörn Zaefferer, http://bassistance.de/ This software consists of voluntary contributions made by many individuals. For exact contribution history, see the revision history -and logs, available at http://github.com/jzaefferer/jqueryvalidation-content +and logs, available at https://github.com/jquery-validation/jqueryvalidation-content Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index 302e805..6308039 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,12 @@ jqueryvalidation-content * libxml2 * libxslt -The `xmllint` and `xsltproc` utilities need to be in your path. If you are on Windows, you can get libxml2 and libxslt from GnuWin32. +The `xmllint` and `xsltproc` utilities need to be in your path. If you are on Windows, you can get libxml2 and libxslt from GnuWin32. * Install [WordPress](http://wordpress.org/download/) * Install [jqueryvalidation-theme](https://github.com/jzaefferer/validation-theme) - clone that repo, then symlink it into your `wp-content/themes` folder -* Install [grunt-wordpress plugin](https://github.com/jquery/jquery-wp-content/blob/master/mu-plugins/grunt-wordpress.php) -* Install [jquery-static-index plugin](https://github.com/jquery/jquery-wp-content/blob/master/plugins/jquery-static-index.php) +* Install [gilded-wordpress plugin](https://raw.githubusercontent.com/scottgonzalez/gilded-wordpress/v1.0.0/gilded-wordpress.php) +* Install [jquery-static-index plugin](https://raw.githubusercontent.com/jquery/jquery-wp-content/v4.0.1/plugins/jquery-static-index.php) ### Installation @@ -23,6 +23,13 @@ In this repo: * run `npm install -g grunt-cli` * run `npm install` +### Hacks + +* Make sure your local `wordpress` nodejs module contains [this commit](https://github.com/scottgonzalez/node-wordpress/commit/2b19238cf8064dafb66b9db09d0adcc9eac7f724) +* Make sure your local config contains + * rpc-auth and basic-auth credentials + * a https jqueryvalidation url + ### Deploy -`grunt deploy` \ No newline at end of file +`grunt deploy` diff --git a/config-sample.json b/config-sample.json index 293c29a..fc44401 100644 --- a/config-sample.json +++ b/config-sample.json @@ -1,6 +1,9 @@ { - "url": "validation.local", + "url": "https://jqueryvalidation.org/", "username": "admin", "password": "secret", - "dir": "dist/wordpress" + "basicAuth": { + "username": "basic-auth-admin", + "password": "basic-auth-secret" + } } diff --git a/entries/Validator.destroy.xml b/entries/Validator.destroy.xml new file mode 100644 index 0000000..89c9714 --- /dev/null +++ b/entries/Validator.destroy.xml @@ -0,0 +1,28 @@ + + + + Validator.destroy() + + + Destroys this instance of validator freeing up resources and unregistering events. + This is only useful, when you need to clean up after the validator in a Single Page Application. + + Destroying an instance of validator. + + + + diff --git a/entries/accept-method.xml b/entries/accept-method.xml index b713cd8..529c1a0 100644 --- a/entries/accept-method.xml +++ b/entries/accept-method.xml @@ -10,7 +10,7 @@

You can specify multiple mime-types by separating them with a comma, e.g. "image/x-eps,application/pdf".

Works with type="file" inputs.

- +

Part of the additional-methods.js file

Note: This method used to look at just the filename, specifically the file extension. That behaviour is now available as the "extension" method inside src/additional/extension.js.

diff --git a/entries/creditcard-method.xml b/entries/creditcard-method.xml index eacb2f8..14a18f5 100644 --- a/entries/creditcard-method.xml +++ b/entries/creditcard-method.xml @@ -5,6 +5,7 @@ Return true if the value is a valid credit card number.

Works with text inputs.

+

Part of the additional-methods.js file

Note: The algorithm used can't verify the validity of the number - it is just an integrity check. As with any other clientside validation, you have to implement the same or better validation on the serverside.

diff --git a/entries/date-method.xml b/entries/date-method.xml index bdeaa86..4d2285b 100644 --- a/entries/date-method.xml +++ b/entries/date-method.xml @@ -1,10 +1,11 @@ - date method + [DEPRECATED] date method Makes the element require a date. Return true if the value is a valid date. Uses JavaScript's built-in Date to test if the date is valid, and therefore does no sanity checks. Only the format must be valid, not the actual date, eg 30/30/2008 is a valid date. -

This method should not be used, since it relies on the new Date constructor, which behaves very differently across browsers and locales. Use dateISO instead or one of the locale specific methods (in localizations/ and additional-methods.js).

+

DEPRECATION warning:

+

This method is deprecated and will be removed in version 2.0.0.
Please don't use it, since it relies on the Date constructor, which behaves very differently across browsers and locales. Use dateISO instead or one of the locale specific methods (in localizations/ and additional-methods.js).

Makes "field" required and a date. diff --git a/entries/email-method.xml b/entries/email-method.xml index 613ad85..b0ba4e9 100644 --- a/entries/email-method.xml +++ b/entries/email-method.xml @@ -5,6 +5,8 @@ Return true if the value is a valid email address.

Works with text inputs.

+

IMPORTANT NOTE:

+

As of version 1.12.0 we started using the same regular expression that the HTML5 specification suggests for browsers to use. We will follow their lead and use the same check. In case you need to adjust the built-in validation regular expression patterns, please use the $.validator.methods property. If you have different requirements, please consider using a custom method.

Makes "field" required and an email address. diff --git a/entries/extension-method.xml b/entries/extension-method.xml index e4bd077..0e8ec9a 100644 --- a/entries/extension-method.xml +++ b/entries/extension-method.xml @@ -5,6 +5,7 @@ Returns true if the value ends with one of the specified file extensions. If nothing is specified, only images are allowed (png, jpeg, gif).

Works with text inputs.

+

Part of the additional-methods.js file

diff --git a/entries/jQuery.validator.addMethod.xml b/entries/jQuery.validator.addMethod.xml index e19d651..59d3fa5 100644 --- a/entries/jQuery.validator.addMethod.xml +++ b/entries/jQuery.validator.addMethod.xml @@ -40,8 +40,17 @@ jQuery.validator.addMethod("domain", function(value, element) { Adds a validation method that checks if a given value equals the addition of the two parameters. +
+ + Adds a custom email validation method that is less strict than the one built-in. + diff --git a/entries/jQuery.validator.format.xml b/entries/jQuery.validator.format.xml index bcf61fd..49c63c5 100644 --- a/entries/jQuery.validator.format.xml +++ b/entries/jQuery.validator.format.xml @@ -26,30 +26,5 @@ var template = jQuery.validator.format("{0} is not a valid value"); alert(template("abc")); ]]>
-
diff --git a/entries/jQuery.validator.methods.xml b/entries/jQuery.validator.methods.xml new file mode 100644 index 0000000..eba2d32 --- /dev/null +++ b/entries/jQuery.validator.methods.xml @@ -0,0 +1,15 @@ + + + + jQuery.validator.methods + Object holding all validation methods known to the validator. This can be accessed to override individual methods, while keeping the default messages. + + Sets a custom email pattern for the built-in email validation rule. + + + + diff --git a/entries/normalizer.xml b/entries/normalizer.xml new file mode 100644 index 0000000..aa13830 --- /dev/null +++ b/entries/normalizer.xml @@ -0,0 +1,128 @@ + + + normalizer + + + The value of the element. + + + Prepares/transforms the elements value for validation. + +

Transform the value of an element and the result for validation instead of the initial value. The normalizer can be defined global to all elements or local to only one element. With that said, the local normalizer will only run for the element for which it was defined. The global normalizer will run for all validated elements. This normalizer can be then overrided for each element, as needed, by attaching one to it. This way only the local one will run for that element, and the global one will run for others.

+

Note that this method:

+
    +
  • Has been available since version 1.15.0

  • +
  • Doesn't change the elements' value, it only changes the value used for validation.

  • +
  • Gets the value passed as argument, and "this" within it references the corresponding DOMElement.

  • +
  • For versions between 1.15.0 and 1.17.0, it must return a string value. And as of 1.17.1, it can return any value including null and undefined.

  • +
+
+ + Makes "field" required and use a normalizer to trim its value before validating + + + + + Makes "url" required and use a normalizer to append 'http://', if not present, to the value of the "url" element before validating + + + + + + Using a global normalizer in conjunction with a local one + + + + +
diff --git a/entries/phoneUS-method.xml b/entries/phoneUS-method.xml index 3dc7956..3490c7e 100644 --- a/entries/phoneUS-method.xml +++ b/entries/phoneUS-method.xml @@ -4,6 +4,7 @@ Validate for valid US phone number. Works with text inputs. +

Part of the additional-methods.js file

Makes "field" required and a US phone number. diff --git a/entries/range-method.xml b/entries/range-method.xml index 72f253e..e050277 100644 --- a/entries/range-method.xml +++ b/entries/range-method.xml @@ -25,7 +25,7 @@ $( "#myform" ).validate({ }); ]]> diff --git a/entries/required-method.xml b/entries/required-method.xml index 827f692..755d1aa 100644 --- a/entries/required-method.xml +++ b/entries/required-method.xml @@ -6,6 +6,7 @@ Return false, if the element is empty (text input) or unchecked (radio/checkbox) or if nothing is selected (select).

Works with text inputs, selects, checkboxes and radio buttons.

To force a user to select an option from a select box, provide an empty option element like <option value="">Choose...</option>

+

Note that white spaces are considered valid.

The element is always required. @@ -28,7 +29,7 @@ - Makes "field" always required. Nothing and blanks are invalid. + Makes "field" always required. and data-rule-[method].

When setting, the rules can also contain a messages-object, specifying custom messages for existing or added rules.

@@ -51,7 +51,7 @@ $( "#myinput" ).rules( "add", { minlength: 2, messages: { required: "Required input", - minlength: jQuery.format("Please, at least {0} characters are necessary") + minlength: jQuery.validator.format("Please, at least {0} characters are necessary") } }); ]]>
diff --git a/entries/step-method.xml b/entries/step-method.xml new file mode 100644 index 0000000..5202f29 --- /dev/null +++ b/entries/step-method.xml @@ -0,0 +1,35 @@ + + + step method + Makes the element require a given step. + + Works with text inputs. No support for input types: date, datetime, datetime-local, month, time and week. + + + + + Step value required + + + + + Makes "field" required and step of 10. + + + + + diff --git a/entries/unchecked-selector.xml b/entries/unchecked-selector.xml index e70c170..427918a 100644 --- a/entries/unchecked-selector.xml +++ b/entries/unchecked-selector.xml @@ -6,7 +6,7 @@
Selects all elements that are unchecked. - Inversion of :checked. + Inversion of :checked. Finds all input elements that are unchecked. @@ -35,4 +35,4 @@ div { color:red; } ]]> - \ No newline at end of file + diff --git a/entries/validate.xml b/entries/validate.xml index 95278ec..640ed6c 100644 --- a/entries/validate.xml +++ b/entries/validate.xml @@ -16,7 +16,7 @@ Enables debug mode. If true, the form is not submitted and certain errors are displayed on the console (will check if a window.console property exists). Try to enable when a form is just submitted instead of validation stopping the submit.

Example: Prevents the form from submitting and tries to help setting up the validation with warnings about missing methods and other debug messages.


-					$(".selector").validate({
+					$("#myform").validate({
 						debug: true
 					});
 					
@@ -25,10 +25,10 @@ - Callback for handling the actual submit when the form is valid. Gets the form as the only argument. Replaces the default submit. The right place to submit a form via Ajax after it is validated. -

Example: Submits the form via Ajax when valid.

+ Callback for handling the actual submit when the form is valid. Gets the form and the submit event as the only arguments. Replaces the default submit. The right place to submit a form via Ajax after it is validated. +

Example: Submits the form via Ajax, using jQuery Form plugin, when valid.


-					$(".selector").validate({
+					$("#myform").validate({
 						submitHandler: function(form) {
 							$(form).ajaxSubmit();
 						}
@@ -36,18 +36,21 @@
 					

Example: Use submitHandler to process something and then using the default submit. Note that "form" refers to a DOM element, this way the validation isn't triggered again.


-					$(".selector").validate({
+					$("#myform").validate({
 						submitHandler: function(form) {
 							// do other things for a valid form
 							form.submit();
 						}
 					});
 					
-

The callback gets passed one argument:

+

The callback gets passed two arguments:

The form currently being validated, as a DOMElement. + + The submit event instance. +
@@ -55,7 +58,7 @@ Callback for custom code when an invalid form is submitted. Called with an event object as the first argument, and the validator as the second.

Example: Displays a message above the form, indicating how many fields are invalid when the user tries to submit an invalid form.


-					$(".selector").validate({
+					$("#myform").validate({
 						invalidHandler: function(event, validator) {
 							// 'this' refers to the form
 							var errors = validator.numberOfInvalids();
@@ -98,7 +101,7 @@
 					Key/value pairs defining custom rules. Key is the name of an element (or a group of checkboxes/radio buttons), value is an object consisting of rule/parameter pairs or a plain String. Can be combined with class/attribute/data rules. Each rule can be specified as having a depends-property to apply the rule only in certain conditions. See the second example below for details.
 					

Example: Specifies a name element as required and an email element as required (using the shortcut for a single rule) and a valid email address (using another object literal).


-					$(".selector").validate({
+					$("#myform").validate({
 						rules: {
 							// simple rule, converted to {required:true}
 							name: "required",
@@ -112,13 +115,31 @@
 					

Example: Specifies a contact element as required and as email address, the latter depending on a checkbox being checked for contact via email.


-					$(".selector").validate({
+					$("#myform").validate({
 						rules: {
 							contact: {
 								required: true,
 								email: {
 									depends: function(element) {
-										return $("#contactform_email:checked")
+										return $("#contactform_email").is(":checked");
+									}
+								}
+							}
+						}
+					});
+					
+

Example: Configure a rule that requires a parameter, along with a depends callback.

+

+					$("#myform").validate({
+						rules: {
+							// at least 15€ when bonus material is included
+							pay_what_you_want: {
+								required: true
+								min: {
+									// min needs a parameter passed to it
+									param: 15,
+									depends: function(element) {
+										return $("#bonus-material").is(":checked");
 									}
 								}
 							}
@@ -133,7 +154,7 @@
 					Key/value pairs defining custom messages. Key is the name of an element, value the message to display for that element. Instead of a plain message, another map with specific messages for each rule can be used. Overrides the title attribute of an element or the default message for the method (in that order). Each message can be a String or a Callback. The callback is called in the scope of the validator, with the rule's parameters as the first argument and the element as the second, and must return a String to display as the message.
 					

Example: Specifies a name element as required and an email element as required and a valid email address. A single message is specified for the name element, and two messages for email.


-					$(".selector").validate({
+					$("#myform").validate({
 						rules: {
 							name: "required",
 							email: {
@@ -150,9 +171,9 @@
 						}
 					});
 					
-

Example: Validates the name-field as required and having at least two characters. Provides a callback message using jQuery.format to avoid having to specify the parameter in two places.

+

Example: Validates the name-field as required and having at least two characters. Provides a callback message using jQuery.validator.format to avoid having to specify the parameter in two places.


-					$(".selector").validate({
+					$("#myform").validate({
 						rules: {
 							name: {
 								required: true,
@@ -162,7 +183,7 @@
 						messages: {
 							name: {
 								required: "We need your email address to contact you",
-								minlength: jQuery.format("At least {0} characters required!")
+								minlength: jQuery.validator.format("At least {0} characters required!")
 							}
 						}
 					});
@@ -191,14 +212,19 @@
 				
 				
 			
+			
+				
+					Prepares/transforms the elements value for validation.
+					See normalizer docs for more details.
+				
+				
+			
 			
 				
 					Validate the form on submit. Set to false to use only other events for validation.
-					

Set to a Function to decide for yourself when to run validation.

-

A boolean true is not a valid value.

Example: Disables onsubmit validation, allowing the user to submit whatever he wants, while still validating on keyup/blur/click events (if not specified otherwise).


-					$(".selector").validate({
+					$("#myform").validate({
 						onsubmit: false
 					});
 					
@@ -210,9 +236,9 @@ Validate elements (except checkboxes/radio buttons) on blur. If nothing is entered, all rules are skipped, except when the field was already marked as invalid.

Set to a Function to decide for yourself when to run validation.

A boolean true is not a valid value.

-

Example: Disables onblur validation.

+

Example: Disables focusout validation.


-					$(".selector").validate({
+					$("#myform").validate({
 						onfocusout: false
 					});
 					
@@ -234,7 +260,7 @@

A boolean true is not a valid value.

Example: Disables onkeyup validation.


-					$(".selector").validate({
+					$("#myform").validate({
 						onkeyup: false
 					});
 					
@@ -251,12 +277,12 @@
- Validate checkboxes and radio buttons on click. Set to false to disable. + Validate checkboxes, radio buttons, and select elements on click. Set to false to disable.

Set to a Function to decide for yourself when to run validation.

A boolean true is not a valid value.

-

Example: Disables onclick validation of checkboxes and radio buttons.

+

Example: Disables onclick validation of checkboxes, radio buttons, and select elements.


-					$(".selector").validate({
+					$("#myform").validate({
 						onclick: false
 					});
 					
@@ -276,7 +302,7 @@ Focus the last active or first invalid element on submit via validator.focusInvalid(). The last active element is the one that had focus when the form was submitted, avoiding stealing its focus. If there was no element focused, the first one in the form gets it, unless this option is turned off.

Example: Disables focusing of invalid elements.


-					$(".selector").validate({
+					$("#myform").validate({
 						focusInvalid: false
 					});
 					
@@ -288,7 +314,7 @@ If enabled, removes the errorClass from the invalid elements and hides all error messages whenever the element is focused. Avoid combination with focusInvalid.

Example: Enables cleanup when focusing elements, removing the error class and hiding error messages when an element is focused.


-					$(".selector").validate({
+					$("#myform").validate({
 						focusCleanup: true
 					});
 					
@@ -300,7 +326,7 @@ Use this class to create error labels, to look for existing error labels and to add it to invalid elements.

Example: Sets the error class to "invalid".


-					$(".selector").validate({
+					$("#myform").validate({
 						errorClass: "invalid"
 					});
 					
@@ -312,7 +338,7 @@ This class is added to an element after it was validated and considered valid.

Example: Sets the valid class to "success".


-					$(".selector").validate({
+					$("#myform").validate({
 						validClass: "success"
 					});
 					
@@ -324,7 +350,7 @@ Use this element type to create error messages and to look for existing error messages. The default, "label", has the advantage of creating a meaningful link between error message and invalid field using the for attribute (which is always used, regardless of element type).

Example: Sets the error element to "em".


-					$(".selector").validate({
+					$("#myform").validate({
 						errorElement: "em"
 					});
 					
@@ -336,7 +362,7 @@ Wrap error labels with the specified element. Useful in combination with errorLabelContainer to create a list of error messages.

Example: Wrap each error element with a list item, useful when using an ordered or unordered list as the error container.


-					$(".selector").validate({
+					$("#myform").validate({
 						wrapper: "li"
 					});
 					
@@ -374,10 +400,10 @@
- A custom message display handler. Gets the map of errors as the first argument and an array of errors as the second, called in the context of the validator object. The arguments contain only those elements currently validated, which can be a single element when doing validation onblur/keyup. You can trigger (in addition to your own messages) the default behaviour by calling this.defaultShowErrors(). + A custom message display handler. Gets the map of errors as the first argument and an array of errors as the second, called in the context of the validator object. The arguments contain only those elements currently validated, which can be a single element when doing validation on focusout or keyup. You can trigger (in addition to your own messages) the default behaviour by calling this.defaultShowErrors().

Example: Update the number of invalid elements each time an error is displayed. Delegates to the default implementation for the actual error display.


-					$(".selector").validate({
+					$("#myform").validate({
 						showErrors: function(errorMap, errorList) {
 							$("#summary").html("Your form contains "
 								+ this.numberOfInvalids()
@@ -458,7 +484,7 @@
 					How to highlight invalid fields. Override to decide which fields and how to highlight.
 					

Example: Highlights an invalid element by fading it out and in again.


-					$(".selector").validate({
+					$("#myform").validate({
 						highlight: function(element, errorClass) {
 							$(element).fadeOut(function() {
 								$(element).fadeIn();
@@ -468,7 +494,7 @@
 					

Example: Adds the error class to both the invalid element and its label


-					$(".selector").validate({
+					$("#myform").validate({
 						highlight: function(element, errorClass, validClass) {
 							$(element).addClass(errorClass).removeClass(validClass);
 							$(element.form).find("label[for=" + element.id + "]")
@@ -505,7 +531,7 @@
 					Set to skip reading messages from the title attribute, helps to avoid issues with Google Toolbar; default is false for compability, the message-from-title is likely to be completely removed in a future release.
 					

Example: Configure the plugin to ignore title attributes on validated elements when looking for messages.


-					$(".selector").validate({
+					$("#myform").validate({
 						ignoreTitle: true
 					});
 					
diff --git a/entries2html.xsl b/entries2html.xsl index 50955aa..bcd622d 100644 --- a/entries2html.xsl +++ b/entries2html.xsl @@ -9,14 +9,14 @@ <head> <meta charset="utf-8"> <title></title> -<link rel="stylesheet" href="http://jquery.bassistance.de/validate/demo/site-demos.css"> +<link rel="stylesheet" href="https://jqueryvalidation.org/files/demo/site-demos.css"> <style> </style> </head> <body> <form id="myform"></form> -<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> -<script src="http://jquery.bassistance.de/validate/jquery.validate.js"></script> -<script src="http://jquery.bassistance.de/validate/additional-methods.js"></script> +<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script> +<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script> +<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script> <script> // just for the demos, avoids form submit jQuery.validator.setDefaults({ diff --git a/grunt.js b/grunt.js deleted file mode 100644 index 94ef222..0000000 --- a/grunt.js +++ /dev/null @@ -1,48 +0,0 @@ -/*jshint node:true */ -module.exports = function( grunt ) { -"use strict"; - -var entryFiles = grunt.file.expandFiles( "entries/*.xml" ); - -grunt.loadNpmTasks( "grunt-clean" ); -grunt.loadNpmTasks( "grunt-wordpress" ); -grunt.loadNpmTasks( "grunt-jquery-content" ); -grunt.loadNpmTasks( "grunt-check-modules" ); - -grunt.initConfig({ - clean: { - folder: "dist" - }, - lint: { - grunt: "grunt.js" - }, - watch: { - files: [ "entries/**", "pages/**", "categories.xml" ], - tasks: "build-xml-entries" - }, - xmllint: { - all: [].concat( entryFiles, "categories.xml", "entries2html.xsl" ) - }, - xmltidy: { - all: [].concat( entryFiles, "categories.xml" ) - }, - "build-pages": { - all: grunt.file.expandFiles( "pages/**" ) - }, - "build-xml-entries": { - all: entryFiles - }, - "build-resources": { - all: grunt.file.expandFiles( "resources/**" ) - }, - wordpress: grunt.utils._.extend({ - dir: "dist/wordpress" - }, grunt.file.readJSON( "config.json" ) ) -}); - -grunt.registerTask( "default", "build-wordpress" ); -grunt.registerTask( "build", "build-pages build-xml-entries build-xml-categories build-xml-full build-resources" ); -grunt.registerTask( "build-wordpress", "check-modules clean lint xmllint build" ); -grunt.registerTask( "tidy", "xmllint xmltidy" ); - -}; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..cfbfc18 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,412 @@ +{ + "name": "jqueryvalidation-content", + "version": "1.0.0", + "lockfileVersion": 1, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, + "argparse": { + "version": "0.1.16", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-0.1.16.tgz", + "integrity": "sha1-z9AeD7uj1srtBJ+9dY1A9lGW9Xw=", + "dependencies": { + "underscore.string": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.4.0.tgz", + "integrity": "sha1-jN2PusTi0uoefi6Al8QvRCKA+Fs=" + } + } + }, + "async": { + "version": "0.1.22", + "resolved": "https://registry.npmjs.org/async/-/async-0.1.22.tgz", + "integrity": "sha1-D8GqoIig4+8Ovi2IMbqw3PiEUGE=" + }, + "cheerio": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-0.17.0.tgz", + "integrity": "sha1-+lrkLMYBIRM9KW0LRtmDIV9yaOo=", + "dependencies": { + "lodash": { + "version": "2.4.2", + "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", + "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=" + } + } + }, + "coffee-script": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.3.3.tgz", + "integrity": "sha1-FQ1rTLUiiUNp7+1qIQHCC8f0pPQ=" + }, + "colors": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", + "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "CSSselect": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/CSSselect/-/CSSselect-0.4.1.tgz", + "integrity": "sha1-+Kt+H4QYzmPNput713ioXX7EkrI=" + }, + "CSSwhat": { + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/CSSwhat/-/CSSwhat-0.4.7.tgz", + "integrity": "sha1-hn2g/zn3eGEyQsRM/qg/CqTr35s=" + }, + "dateformat": { + "version": "1.0.2-1.2.3", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.2-1.2.3.tgz", + "integrity": "sha1-sCIMAt6YYXQztyhRz0fePfLNvuk=" + }, + "dom-serializer": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.0.1.tgz", + "integrity": "sha1-lYmCfx4y0iw3yCmtq9WbMkevjq8=", + "dependencies": { + "domelementtype": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", + "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=" + } + } + }, + "domelementtype": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", + "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=" + }, + "domhandler": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.2.1.tgz", + "integrity": "sha1-Wd+dzSJ+gIs2Wuc+H2aErD2Ub8I=" + }, + "domutils": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.4.3.tgz", + "integrity": "sha1-CGVRN5bGswYDGFDhdVFrr4C3Km8=" + }, + "entities": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", + "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=" + }, + "esprima": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", + "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=" + }, + "eventemitter2": { + "version": "0.4.14", + "resolved": "http://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", + "integrity": "sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=" + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=" + }, + "findup-sync": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.1.3.tgz", + "integrity": "sha1-fz56l7gjksZTvwZYm9hRkOk8NoM=", + "dependencies": { + "glob": { + "version": "3.2.11", + "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", + "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=" + }, + "lodash": { + "version": "2.4.2", + "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", + "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=" + }, + "minimatch": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", + "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=" + } + } + }, + "getobject": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/getobject/-/getobject-0.1.0.tgz", + "integrity": "sha1-BHpEl4n6Fg0Bj1SG7ZEyC27HiFw=" + }, + "gilded-wordpress": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gilded-wordpress/-/gilded-wordpress-1.0.0.tgz", + "integrity": "sha1-xqLn1wetWX2pMQdeAcL+iBtttaA=", + "dependencies": { + "async": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" + }, + "glob": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-4.0.6.tgz", + "integrity": "sha1-aVxQvdTi+1xdNwsJHziNNwfikac=" + }, + "graceful-fs": { + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", + "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=" + }, + "minimatch": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-1.0.0.tgz", + "integrity": "sha1-4N0hILSeG3JM6NcUxSCCKpQ4V20=" + } + } + }, + "glob": { + "version": "3.1.21", + "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", + "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", + "dependencies": { + "inherits": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", + "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=" + } + } + }, + "graceful-fs": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", + "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=" + }, + "grunt": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/grunt/-/grunt-0.4.5.tgz", + "integrity": "sha1-VpN81RlDJK3/bSB2MYMqnWuk5/A=" + }, + "grunt-check-modules": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/grunt-check-modules/-/grunt-check-modules-1.0.0.tgz", + "integrity": "sha1-Y/9erkYTF5tKifaozTcfekAfd4I=" + }, + "grunt-jquery-content": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/grunt-jquery-content/-/grunt-jquery-content-2.0.0.tgz", + "integrity": "sha1-jVFDOs0z/n7VL9956gAxwCRSwII=", + "dependencies": { + "async": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.0.tgz", + "integrity": "sha1-rDYTsdqb7RtHUQu0ZRuJMeRxRsc=" + }, + "which": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/which/-/which-1.0.5.tgz", + "integrity": "sha1-VjDWgZ3aaS8UZEYueVbLQsCEJzk=" + } + } + }, + "grunt-legacy-log": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/grunt-legacy-log/-/grunt-legacy-log-0.1.3.tgz", + "integrity": "sha1-7ClCboAwIa9ZAp+H0vnNczWgVTE=", + "dependencies": { + "lodash": { + "version": "2.4.2", + "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", + "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=" + }, + "underscore.string": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.3.tgz", + "integrity": "sha1-ccCL9rQosRM/N+ePo6Icgvcymw0=" + } + } + }, + "grunt-legacy-log-utils": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/grunt-legacy-log-utils/-/grunt-legacy-log-utils-0.1.1.tgz", + "integrity": "sha1-wHBrndkGThFvNvI/5OawSGcsD34=", + "dependencies": { + "lodash": { + "version": "2.4.2", + "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", + "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=" + }, + "underscore.string": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.3.tgz", + "integrity": "sha1-ccCL9rQosRM/N+ePo6Icgvcymw0=" + } + } + }, + "grunt-legacy-util": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/grunt-legacy-util/-/grunt-legacy-util-0.2.0.tgz", + "integrity": "sha1-kzJIhNv343qf98Am3/RR2UqeVUs=" + }, + "grunt-wordpress": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/grunt-wordpress/-/grunt-wordpress-2.1.0.tgz", + "integrity": "sha1-ty0EttVbQdFP/Yrq8W0ibFk9vl0=" + }, + "he": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/he/-/he-0.5.0.tgz", + "integrity": "sha1-LAX/rvkLaOhg8/0rVO9YCYknfuI=" + }, + "highlight.js": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-7.3.0.tgz", + "integrity": "sha1-bF8PZOcHj2ZAK82/yJEQw/0bqZ8=" + }, + "hooker": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", + "integrity": "sha1-uDT3I8xKJCqmWWNFnfbZhMXT2Vk=" + }, + "htmlparser2": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.7.3.tgz", + "integrity": "sha1-amTHdjfAjG8w7CqBV6UzM758sF4=", + "dependencies": { + "domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=" + }, + "entities": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", + "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=" + } + } + }, + "iconv-lite": { + "version": "0.2.11", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.2.11.tgz", + "integrity": "sha1-HOYKOleGSiktEyH/RgnKS7llrcg=" + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "js-yaml": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-2.0.5.tgz", + "integrity": "sha1-olrmUJmZ6X3yeMZxnaEb0Gh3Q6g=" + }, + "lodash": { + "version": "0.9.2", + "resolved": "http://registry.npmjs.org/lodash/-/lodash-0.9.2.tgz", + "integrity": "sha1-jzSZxSRdNG1oLlsNO0B2fgnxqSw=" + }, + "lru-cache": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", + "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=" + }, + "marked": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.2.tgz", + "integrity": "sha1-AV2xWIZEOPJKZL3WGgQotBhwbQk=" + }, + "minimatch": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", + "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=" + }, + "natives": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.4.tgz", + "integrity": "sha512-Q29yeg9aFKwhLVdkTAejM/HvYG0Y1Am1+HUkFQGn5k2j8GS+v60TVmZh6nujpEAj/qql+wGUrlryO8bF+b1jEg==" + }, + "nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=" + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=" + }, + "rimraf": { + "version": "2.2.8", + "resolved": "http://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", + "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=" + }, + "sax": { + "version": "0.4.3", + "resolved": "http://registry.npmjs.org/sax/-/sax-0.4.3.tgz", + "integrity": "sha1-cA46NOsueSzjgHkccSgPNzGWXdw=" + }, + "sigmund": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", + "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=" + }, + "spawnback": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/spawnback/-/spawnback-1.0.0.tgz", + "integrity": "sha1-9zZi9+VNlTZ+ynTWQmxnfdfqaG8=" + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + }, + "underscore": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", + "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=" + }, + "underscore.string": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.2.1.tgz", + "integrity": "sha1-18D6KvXVoaZ/QlPa7pgTLnM/Dxk=" + }, + "which": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/which/-/which-1.0.9.tgz", + "integrity": "sha1-RgwdoPgQED0DIam2M6+eV15kSG8=" + }, + "wordpress": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordpress/-/wordpress-1.0.0.tgz", + "integrity": "sha1-m+FQ5pObYUnVw0F017UIeOK7s88=" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "xmlbuilder": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-0.3.1.tgz", + "integrity": "sha1-XtTCK0YiwkN/r4Pk8jbyPWu/JkE=" + }, + "xmlrpc": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xmlrpc/-/xmlrpc-1.0.1.tgz", + "integrity": "sha1-QZcSWnn5mG1Ih2cVqC0Gj+8WiuM=" + } + } +} diff --git a/package.json b/package.json index 580f466..77f8011 100644 --- a/package.json +++ b/package.json @@ -3,28 +3,25 @@ "title": "jQuery Validation Plugin site content", "description": "Site content for the jQuery Validation Plugin", "version": "1.0.0", - "homepage": "http://validation.bassistance.de", + "homepage": "https://jqueryvalidation.org/", "author": { "name": "Jörn Zaefferer (http://bassistance.de/)" }, "repository": { "type": "git", - "url": "git://github.com/jzaefferer/jqueryvalidation-content.git" + "url": "git://github.com/jquery-validation/validation-content.git" }, "bugs": { - "url": "https://github.com/jzaefferer/jqueryvalidation-content/issues" + "url": "https://github.com/jquery-validation/validation-content/issues" }, "licenses": [ { "type": "MIT", - "url": "http://www.opensource.org/licenses/MIT" + "url": "https://opensource.org/licenses/MIT" } ], "dependencies": { - "grunt": "0.3.17", - "grunt-clean": "0.3.0", - "grunt-wordpress": "1.0.7", - "grunt-jquery-content": "0.9.0", - "grunt-check-modules": "0.1.0" + "grunt": "0.4.5", + "grunt-jquery-content": "2.0.0" } } diff --git a/pages/contribute.md b/pages/contribute.md index 4c2cf3c..6b403a0 100644 --- a/pages/contribute.md +++ b/pages/contribute.md @@ -4,8 +4,8 @@ There are several ways for you to contribute to this plugin: -* Help [with the code](https://github.com/jzaefferer/jquery-validation/). Fix bugs, propose features, translate messages and methods... -* Help [with the site content](https://github.com/jzaefferer/validation-content). Improve API documentation, examples, references... -* Help [with the site theme](https://github.com/jzaefferer/validation-theme). This is a WordPress theme that still needs a lot of improvements. +* Help [with the code](https://github.com/jquery-validation/jquery-validation/). Fix bugs, propose features, translate messages and methods... +* Help [with the site content](https://github.com/jquery-validation/validation-content). Improve API documentation, examples, references... +* Help [with the site theme](https://github.com/jquery-validation/validation-theme). This is a WordPress theme that still needs a lot of improvements. -The majority of contributions can be viewed under [jQuery's contribute site](http://contribute.jquery.org/) - the style guides et al apply to this project as well. \ No newline at end of file +The majority of contributions can be viewed under [jQuery's contribute site](https://contribute.jquery.org/) - the style guides et al apply to this project as well. diff --git a/pages/documentation.md b/pages/documentation.md index 1645411..97fa99f 100644 --- a/pages/documentation.md +++ b/pages/documentation.md @@ -11,7 +11,7 @@ You may need different ways to specify validation rules according to the server- **"But aren't there already a ton of validation plugins out there?"** Right, there are a lot of non-jQuery-based solutions (which you'd avoid since you found jQuery) and some jQuery-based solutions. This particular one is one of the oldest jQuery plugins (started in July 2006) and has proved itself in projects all around the world. There is also an [article](http://bassistance.de/2007/07/04/about-client-side-form-validation-and-frameworks/) discussing how this plugin fits the bill of the should-be validation solution. -Not convinced? [Have a look at this example](http://jquery.bassistance.de/validate/demo/): +Not convinced? [Have a look at this example](https://jqueryvalidation.org/files/demo/):

 
@@ -95,6 +95,7 @@ The validate method returns a Validator object that has a few public methods tha * [`Validator.resetForm()` - Resets the controlled form.](/Validator.resetForm) * [`Validator.showErrors()` - Show the specified messages.](/Validator.showErrors) * [`Validator.numberOfInvalids()` - Returns the number of invalid fields.](/Validator.numberOfInvalids) +* [`Validator.destroy()` - Destroys this instance of validator.](/Validator.destroy) There are a few static methods on the validator object: @@ -110,27 +111,32 @@ A set of standard validation methods is provided: * [`required` - Makes the element required.](/required-method) * [`remote` - Requests a resource to check the element for validity.](/remote-method) * [`minlength` - Makes the element require a given minimum length.](/minlength-method) -* [`maxlength` - Makes the element require a given maxmimum length.](/maxlength-method) +* [`maxlength` - Makes the element require a given maximum length.](/maxlength-method) * [`rangelength` - Makes the element require a given value range.](/rangelength-method) * [`min` - Makes the element require a given minimum.](/min-method) * [`max` - Makes the element require a given maximum.](/max-method) * [`range` - Makes the element require a given value range.](/range-method) +* [`step` - Makes the element require a given step.](/step-method) * [`email` - Makes the element require a valid email](/email-method) * [`url` - Makes the element require a valid url](/url-method) * [`date` - Makes the element require a date.](/date-method) * [`dateISO` - Makes the element require an ISO date.](/dateISO-method) * [`number` - Makes the element require a decimal number.](/number-method) * [`digits` - Makes the element require digits only.](/digits-method) -* [`creditcard` - Makes the element require a credit card number.](/creditcard-method) * [`equalTo` - Requires the element to be the same as another one](/equalTo-method) Some more methods are provided as add-ons, and are currently included in additional-methods.js in the download package. Not all of them are documented here: * [`accept` - Makes a file upload accept only specified mime-types.](/accept-method) +* [`creditcard` - Makes the element require a credit card number.](/creditcard-method) * [`extension` - Makes the element require a certain file extension.](/extension-method) * [`phoneUS` - Validate for valid US phone number.](/phoneUS-method) * [`require_from_group` - Ensures a given number of fields in a group are complete.](/require_from_group-method) +You can find the [source code for all additional methods in the GitHub repository](https://github.com/jzaefferer/jquery-validation/tree/master/src/additional). + +It is possible to re-define the implementation of the built-in rules using the [`$.validator.methods` property](/jQuery.validator.methods/) + # [General Guidelines](/reference) The General Guidelines section provides detailed discussion of the design and ideas behind the plugin, explaining why certain things are as they are. It covers the features in more detail than the API documentation, which just briefly explains the various methods and options available. @@ -170,8 +176,8 @@ So the correct code looks slightly different: # Demos -## [The Marketo sign-up form](http://jquery.bassistance.de/validate/demo/marketo/) -### [The Marketo sign-up form, step 2](http://jquery.bassistance.de/validate/demo/marketo/step2.htm) +## [The Marketo sign-up form](https://jqueryvalidation.org/files/demo/marketo/) +### [The Marketo sign-up form, step 2](https://jqueryvalidation.org/files/demo/marketo/step2.htm) Based on an old version of the marketo.com sign-up form. The custom validation was once replaced with this plugin. Thanks to Glen Lipka for contributing it! *Notable features of the demo:* @@ -182,7 +188,7 @@ Based on an old version of the marketo.com sign-up form. The custom validation w * A custom method for making the billing address on step 2 optional when "Same as Company Address" is checked * A custom method for checking the password: Checks that the password contains at least one number and one character and that it is at least 6 characters long. If the user blurs the field with an invalid value, the input is emptied and gets focus again. -## [The Remember The Milk sign-up form](http://jquery.bassistance.de/validate/demo/milk/) +## [The Remember The Milk sign-up form](https://jqueryvalidation.org/files/demo/milk/) The sign-up form from rememberthemilk.com (based on an older version). The custom validation was replaced using this plugin. Thanks to RTM for contributing! *Notable features of the demo:* @@ -190,7 +196,7 @@ The sign-up form from rememberthemilk.com (based on an older version). The custo * Custom message display, based on the original table layout, using success option to display a checkmark for valid fields * Remote validation of username, to check if it is already taken (try "Peter", "asdf" or "George") -## [A multipart "buy&sell a house" form](http://jquery.bassistance.de/validate/demo/multipart/) +## [A multipart "buy&sell a house" form](https://jqueryvalidation.org/files/demo/multipart/) Contributed by Michael Evangelista, showing a multipart form for buying and selling houses. *Notable features of the demo:* @@ -198,8 +204,8 @@ Contributed by Michael Evangelista, showing a multipart form for buying and sell * Multipart, implemented using the jQuery UI accordion and a custom method to check if an element is on the current page when validated * Integration with masked-input plugin, see Phone and Zip fields -## [Using remote validation to help with captchas](http://jquery.bassistance.de/validate/demo/captcha/) -Features remote validation for helping the user to fill out captchas, based on example at [psyrens.com](http://psyrens.com/captcha/). +## [Using remote validation to help with captchas](https://jqueryvalidation.org/files/demo/captcha/) +Features remote validation for helping the user to fill out captchas. *Notable features of the demo:* diff --git a/pages/index.html b/pages/index.html index 8d2010f..d6df4f7 100644 --- a/pages/index.html +++ b/pages/index.html @@ -4,51 +4,56 @@

This jQuery plugin makes simple clientside form validation easy, whilst still offering plenty of customization options. It makes a good choice if you’re building something new from scratch, but also when you’re trying to integrate something into an existing application with lots of existing markup. The plugin comes bundled with a useful set of validation methods, including URL and email validation, while providing an API to write your own methods. All bundled methods come with default error messages in english and translations into 37 other languages.

-

If you want to support the development of this plugin, please donate to the ongoing pledgie.org campagin.

+

For a quick overview of what this plugin provides, check out this Webucator video (they also provide jQuery trainings):

+ -Click here to lend your support to: jQuery Validation Plugin and make a donation +

The plugin was initially written and maintained by Jörn Zaefferer, a member of the jQuery team, lead developer on the jQuery UI team and maintainer of QUnit. It was started back in the early days of jQuery in 2006, and updated and improved since then.

+

Starting with Version 1.15.0 Markus Staab took over the maintenance of the codebase in February 2016. Since July 2016 Brahim Arkni assisted Markus, and a few months later Brahim joined the jQuery Validation core team.

-

The plugin is written and maintained by Jörn Zaefferer, a member of the jQuery team, lead developer on the jQuery UI team and maintainer of QUnit. It was started back in the early days of jQuery in 2006, and updated and improved since then.

- -
Current version: 1.12.0
+
Current version: 1.19.5
License: MIT

Files:

-Download -Changelog -Demos -Documentation +Download +Changelog +Demos +Documentation GitHub Repository -GitHub 1.12.0 Tag

Installation via Package Managers

    -
  • Bower: bower install jquery.validation
  • +
  • Bower: bower install jquery-validation
  • NuGet: Install-Package jQuery.Validation
  • +
  • NPM: npm i jquery-validation

-1.12.0 files on Microsoft's Ajax CDN (hotlinking welcome):

+Latest files on jsDelivr CDN (hotlinking welcome): +

+Latest files on cdnjs CDN (hotlinking welcome):

+ + +

Dependencies

Required

Support

    -
  • Please post questions to the official using jQuery Plugins Forum, tagging your question with (at least) "validate". Keep your question short and succinct and provide code when possible; a testpage makes it much more likely that you get an useful answer in a shorter time.
  • +
  • Please post questions to the official using jQuery Plugins Forum, tagging your question with (at least) "validate". Keep your question short and succinct and provide code when possible; a testpage makes it much more likely that you get an useful answer in a shorter time.
  • Please post bug reports and other contributions (enhancements, features, eg. new validation methods) to the GitHub issue tracker
- -

Donate

-Click here to lend your support to: jQuery Validation Plugin and make a donation at www.pledgie.com ! \ No newline at end of file diff --git a/pages/reference.md b/pages/reference.md index 55b35be..535c9b6 100644 --- a/pages/reference.md +++ b/pages/reference.md @@ -1,5 +1,5 @@ # Goals @@ -7,27 +7,28 @@ The ultimate goal of this plugin is to make working with forms more fun for ever To achieve this, it is important that the plugin is actually deployed on websites around the world, so a lot of focus is spent on making it easy for developers - that's you - to use the plugin. -The plugin can never replace serverside validation and doesn't intend to do so. Having both in place gives you the necessary security for your application, as well as improved usability. +The plugin can never replace server-side validation and doesn't intend to do so. Having both in place gives you the necessary security for your application, as well as improved usability. # Markup recommendations -Each input has a label associated with it: The for-attribute of the label refers to the id-attribute of the input. -

+Mandated: A 'name' attribute is required for all input elements needing validation, and the plugin will not work without this. A 'name' attribute must also be unique to the form, as this is how the plugin keeps track of all input elements. However, each group of radio or checkbox elements will share the same 'name' since the value of this grouping represents a single piece of the form data.
+
+Optionally: Each input can have a label associated with it, where the 'for' attribute of the label refers to the 'id' attribute of the input. It's also a common practice to have 'id' and 'name' attributes with the same value, although keep in mind that since this plugin does not use the 'id' attribute, this is not mandatory.
+
+```html
 
 
-
- -The name attribute is '''required''' for input elements, the validation plugin doesn't work without it. Usually name and id attributes should have the same value. +``` # Methods -A validation method implements the logic to validate any element. Provided are a set of default validation methods, such as required. Apart from required itself and equalTo, all validation methods declare an element valid when it has no value at all. That way an email field is optional unless required is specified. You can specify an element input to contain a valid email address, or nothing at all. Use jQuery.validator.addMethod to implement custom methods. +A validation method implements the logic to validate any element. Provided are a set of default validation methods, such as `required`. Apart from `required` itself and `equalTo`, all validation methods declare an element valid when it has no value at all. That way an email field is optional unless `required` is specified. You can specify an element input to contain a valid email address, or nothing at all. Use jQuery.validator.addMethod to implement custom methods. # Rules -A validation rule applies one or more validation methods to an input element. You can specify validation rules via metadata or via plugin settings (option rules). The decision is often influenced by serverside infrastructure. If a web framework is used, it is often easier to use metadata, which is also good for fast prototyping. Plugin settings produce cleaner markup, though valid markup results from both. +A validation rule applies one or more validation methods to an input element. You can specify validation rules via metadata or via plugin settings (option `rules`). The decision is often influenced by serverside infrastructure. If a web framework is used, it is often easier to use metadata, which is also good for fast prototyping. Plugin settings produce cleaner markup, though valid markup results from both. ## Fields with complex names (brackets, dots) -If your form consists of fields using names that aren't legal JavaScript identifiers, you have to quote those names when using the rules option: +If your form consists of fields using names that aren't legal JavaScript identifiers, you have to quote those names when using the `rules` option: -

+```js
  $("#myform").validate({
    rules: {
      // no quoting necessary
@@ -38,71 +39,91 @@ If your form consists of fields using names that aren't legal JavaScript identif
      "user.address.street": "required"
    }
  });
-
+``` ## Refactoring rules -Whenever you have multiple fields with the same rules and messages, refactoring those can reduce a lot of duplication. Using addMethod and addClassRules are most effective for that. +Whenever you have multiple fields with the same rules and messages, refactoring those can reduce a lot of duplication. Using `addMethod()` and `addClassRules()` are most effective for that. Let's consider an example where you have ten customer fields, each required and with a minlength of 2. You need custom messages for both rules. To avoid having to specify those rules and messages again and again, we can alias existing methods with different messages and group them into a single class: -

+```js
  // alias required to cRequired with new message
  $.validator.addMethod("cRequired", $.validator.methods.required,
    "Customer name required");
  // alias minlength, too
  $.validator.addMethod("cMinlength", $.validator.methods.minlength,
    // leverage parameter replacement for minlength, {0} gets replaced with 2
-   $.format("Customer name must have at least {0} characters"));
+   $.validator.format("Customer name must have at least {0} characters"));
  // combine them both, including the parameter for minlength
  $.validator.addClassRules("customer", { cRequired: true, cMinlength: 2 });
-
+``` With that in place, we can add a class customer to all customer fields and be done with it: -

+```html
  
  
  
-
+``` + +You can also reuse existing methods inside other custom methods, to reuse certain implementations. For example, if you're writing a custom method for validating email addresses inside a single field, you could call the existing `email` method for each email: + +```js +jQuery.validator.methods.email.call(this, email, element) +``` # Error messages -An error message displays a hint for the user about invalid elements, and what is wrong. There are three ways to provide error messages. Via the title attribute of the input element to validate, via error labels and via plugin settings (option messages). +An error message displays a hint for the user about invalid elements, and what is wrong. There are four ways to provide error messages. Via the title attribute of the input element to validate, via data attributes, via error labels and via plugin settings (option `messages`). All validation rules included here provide a default error message which you can use for prototyping, because it is used when no specific message is provided. The priorities are as follows: A custom message (passed by plugin options), the element's title, the default message. +When using data attributes, you can set a generic message for all rules, or specific messages per rule: +```html + + +``` + # Error message display -Error messages are handled via label elements with an additional class (option errorClass). The link between the message and the invalid element is provided via the labels for attribute. When provided in the markup, they are shown and hidden accordingly, and otherwise created on demand. By default, labels are created after the invalid element, this is also customizable (option errorPlacement). It is also possible to put them into an error container (option errorLabelContainer). To use a different element then a label, specify the errorElement option. +Error messages are handled via label elements with an additional class (option `errorClass`). The link between the message and the invalid element is provided via the labels for attribute. When provided in the markup, they are shown and hidden accordingly, and otherwise created on demand. By default, labels are created after the invalid element, this is also customizable (option `errorPlacement`). It is also possible to put them into an error container (option `errorLabelContainer`). To use a different element then a label, specify the `errorElement` option. # General messages -In addition to field-specific messages you can display a general "your form is invalid, please fix the highlighted fields!" message in a container anywhere on your page, eg. above the form (option errorContainer). The container is shown and hidden when errors occur and are fixed accordingly. The container for error labels (option errorLabelContainer) can also be nested inside the error container. +In addition to field-specific messages you can display a general "your form is invalid, please fix the highlighted fields!" message in a container anywhere on your page, eg. above the form (option `errorContainer`). The container is shown and hidden when errors occur and are fixed accordingly. The container for error labels (option `errorLabelContainer`) can also be nested inside the error container. # Focusing of invalid elements -By default, the first invalid element in a form is focused after submitting a form with invalid elements. To prevent confusion on the behalf of the user, the plugin remembers the element that had focus when the form was submitted, and refocuses that element. That way the user can try to fill out elements of the form at the end, without being forced to focus them again and again. This can be disabled (option focusInvalid). +By default, the first invalid element in a form is focused after submitting a form with invalid elements. To prevent confusion on the behalf of the user, the plugin remembers the element that had focus when the form was submitted, and refocuses that element. That way the user can try to fill out elements of the form at the end, without being forced to focus them again and again. This can be disabled (option `focusInvalid`). # Form submit -By default, the form submission is prevented when the form is invalid, and submitted as normal when it is valid. You can also handle the submission manually (option submitHandler). +By default, the form submission is prevented when the form is invalid, and submitted as normal when it is valid. You can also handle the submission manually (option `submitHandler`). ## Skipping validation on submit -To skip validation while still using a submit-button, add a class="cancel" to that input. +To skip validation while still using a submit-button, add the attribute "formnovalidate" to that input: + +```html + + +``` -

- 
- 
-
+This used to work by adding `class="cancel"` to the input, this is now deprecated. -[Demo for the cancel button](http://jquery.bassistance.de/validate/demo/errorcontainer-demo.html) +[Demo for the cancel button](https://jqueryvalidation.org/files/demo/errorcontainer-demo.html) # Validation event -By default, forms are validated on submit, triggered by the user clicking the submit button or pressing enter when a form input is focused (option onsubmit). In addition, once a field was highlighted as being invalid, it is validated whenever the user types something in the field (option onkeyup). When the user enters something invalid into a valid field, it is also validated when the field loses focus (option onblur). +By default, forms are validated on submit, triggered by the user clicking the submit button or pressing enter when a form input is focused (option `onsubmit`). In addition, once a field was highlighted as being invalid, it is validated whenever the user types something in the field (option `onkeyup`). When the user enters something invalid into a valid field, it is also validated when the field loses focus (option `onfocusout`). The goal of these interactions is to provide feedback as early as possible, whilst avoiding user annoyance. Displaying error messages before the user had the chance to even type something is not helpful. # Developing and debugging a form -While developing and debugging the form, you should set the debug option to true. That prevents form submission on both valid and invalid forms and outputs some helpful messages to window.console (available via Firebug or Firebug Lite) that help debugging. When you have everything set up and don't get any error messages displayed, check if your rules all accept empty elements as valid (like email or url methods). +While developing and debugging the form, you should set the `debug` option to true. That prevents form submission on both valid and invalid forms and outputs some helpful messages to window.console (available via Firebug or Firebug Lite) that help debugging. When you have everything set up and don't get any error messages displayed, check if your rules all accept empty elements as valid (like email or url methods). Some issues are caused by certain form element's names. A name you should avoid is "submit" (for submit buttons and anything else). Browsers expose form elements as properties of the form element, by their name, in this case hiding native methods like submit(). Just don't use name="submit" and you're good. # Validating multiple forms on one page -The plugin can handle only one form per call. In case you have multiple forms on a single page which you want to validate, you can avoid having to duplicate the plugin settings by modifying the defaults. Use jQuery.validator.setDefaults to override multiple settings at once. \ No newline at end of file +The plugin can handle only one form per call. In case you have multiple forms on a single page which you want to validate, you have to initialise them all individually: +```js +$( "form" ).each( function() { + $( this ).validate( options ); +} ); +``` +You can avoid having to duplicate the plugin settings by modifying the defaults, using jQuery.validator.setDefaults to override multiple settings at once.