From 851c4afb5816a2fe3f4975ebd8f04735ed7755d3 Mon Sep 17 00:00:00 2001 From: Victor Jonsson Date: Sat, 2 Feb 2019 08:48:03 +0100 Subject: [PATCH 1/4] Update README.md --- README.md | 244 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 241 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e02a533..d3002ae 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# jQuery Form Validator +# jQuery Form Validator [DISCONTINUED] *Validation framework that let's you configure, rather than code, your validation logic.* I started writing this plugin back in 2009 and it has given me much joy over the years. But all good things must come to an end and now it's time for this plugin to pull in its oars and go down with history. -**NOTICE!** This plugin is no longer being developed! It supports jQuery v. 1.8 >= 2.2.4. No pull requests will become merged in but feel free to fork and do whatever you like! +**This plugin is no longer being developed!** It supports jQuery v. 1.8 >= 2.2.4. No pull requests will become merged in but feel free to fork and do whatever you like! [![Travis](https://travis-ci.org/victorjonsson/jQuery-Form-Validator.svg)](https://travis-ci.org/victorjonsson/jQuery-Form-Validator/builds/) @@ -82,7 +82,7 @@ Read the documentation for the default features at [#default-validators](#defaul * **letternumeric** — *Validate that the input value consists out of only letters and/or numbers* * **recaptcha** - *Validate Google [reCaptcha 2](https://www.google.com/recaptcha/intro/index.html)* -Read the documentation for the security module at [http://formvalidator.net/#security-validators](http://formvalidator.net/#security-validators) +Read the documentation for the security module at [#security-validators](#security-validators) ### Module: date * **time** — *hh:mm* @@ -487,6 +487,244 @@ You can tell any validator to ignore certain characters by using the attribute d

``` +## Security validators< + +### Password confirmation + +This validator can be used to validate that the values of two inputs are the same. The first input should have a name suffixed with _confirmation and the second should have the same name but without the suffix. + +``` +

+ Password (at least 8 characters) + + + Confirm password + +

+``` + +``` +

+ E-mail + + + Repeat e-mail + +

+``` + +### Password strength + +Use this validator to make sure that your user has a strong enough password. Set attribute data-validation-strength to 1, 2 or 3 depending on how strong password you require. + +If you want the strength of the password to be displayed while the user types you call displayPasswordStrength() in the end of the form. + +``` +
+

+ Password: + +

+ ... +
+ + + + +``` + +### Server side validation + +By using this validator you can validate the value given by the user on the server before the form gets submitted. The validation function will send a POST request to the URL declared in data-validation-url. The argument posted to the URL will have the same name as the input being validated. + +The form will get the class validating-server-side while the server is being requested. + +The response from the validation script must be a JSON formatted object, containing the properties "valid" and "message". + +``` +{ + "valid" : true|false, + "message" : "String with text that should be displayed as error message" +} +``` + +#### Form + +``` +
+

+ User name: + +

+ ... +
+``` + +#### /validate-input.php + +``` + false, + 'message' => 'Post argument "user" is missing.' +); + +if( isset($_POST['user']) ) { + $userRepo = new UserRepository( DataStorage::instance() ); + $user = $userRepo->loadUser( $_POST['user'] ); + + if( $user ) { + // User name is registered on another account + $response = array('valid' => false, 'message' => 'This user name is already registered.'); + } else { + // User name is available + $response = array('valid' => true); + } +} +echo json_encode($response); +``` + +**Modifying the server request** + +The parameter containing the input value, sent to the server, will by default have the same name as the input. You can however set your own parameter name by using the attribute data-validation-param-name. You can also send along other parameters to the server by using the attribute data-validation-req-params. + +``` +$user->get('ID'))); +?> +

+ E-mail: + +

+``` + +### Credit card validation + +This validator makes it possible to validate any of the credit cards VISA, Mastercard, Diners club, Maestro, CJB, Discover and American express + +``` +<-- Accept credit card number from Visa, Mastercard and American Express --> +

+ Credit card number + +

+

+ Security code (cvv) + +

+``` + +You can also let the user choose a credit card and programmatically change the allowed credit card on the input of the card number. + +``` +

+ Credit card + +

+

+ Credit card number + +

+... + + +``` + +### Simple captcha + +``` + +
+

+ What is the sum of + ? + (security question) + +

+

+
+``` + +### Google reCAPTCHA + +Use this validator if wanting to integrate the Google service reCAPTCHA. + +``` +

+ +

+``` + +You can also use the setup function to configure the recaptcha service. + +``` +$.validate({ + reCaptchaSiteKey: '...', + reCaptchaTheme: 'light' +}); +``` + +### Letters and numbers + +By using the validator letternumeric you can validate that given input value only contains letters and/or numbers. This validator allows any type of character in contrast to the alphanumeric validator, which only allows letters A-Z. + +``` + + + + + +``` + ## Changelog #### 2.3.19 From fb8b52f3792c152c13c59975abb8eac8e3a6809b Mon Sep 17 00:00:00 2001 From: Victor Jonsson Date: Sat, 2 Feb 2019 08:53:27 +0100 Subject: [PATCH 2/4] Update README.md --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d3002ae..78defb0 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ Read the documentation for the security module at [#security-validators](#securi * **time** — *hh:mm* * **birthdate** — *yyyy-mm-dd, not allowing dates in the future or dates that's older than 122 years (format can be customized, more information below)* -Read the documentation for the date module at [http://formvalidator.net/#date-validators](http://formvalidator.net/#date-validators) +Read the documentation for the date module at [#date-validators](#date-validators) ### Module: location * **country** @@ -725,6 +725,30 @@ By using the validator letternumeric you can validate that given in ``` +## Date validators + +### Birthdate + +This validator is the same as the default date validator except that it only allows past dates and dates that is not older than 120 years. + +``` + + + + + + + + +``` + +## Time + +``` + + +``` + ## Changelog #### 2.3.19 From a4c458fb0b52be9e474156f81aad527af24def8a Mon Sep 17 00:00:00 2001 From: Victor Jonsson Date: Sat, 2 Feb 2019 09:02:15 +0100 Subject: [PATCH 3/4] Update README.md --- README.md | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 129 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 78defb0..7d25e02 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Read the documentation for the date module at [#date-validators](#date-validator * Suggest countries (english only) * Suggest states in the US -Read the documentation for the location module at [http://formvalidator.net/#location-validators](http://formvalidator.net/#location-validators) +Read the documentation for the location module at [#location-validators](/#location-validators) ### Module: file * **mime** @@ -105,7 +105,7 @@ Read the documentation for the location module at [http://formvalidator.net/#loc * **size** (file size) * **dimension** (size dimension and ratio) -Read the documentation for the file module at [http://formvalidator.net/#file-validators](http://formvalidator.net/#file-validators) +Read the documentation for the file module at [#file-validators](#file-validators) ### Module: logic @@ -749,6 +749,133 @@ This validator is the same as the default da ``` + +## Location validators + +### Country + +``` + + +``` + +### State (US) + +``` + + +``` + +### Longitude and Latitude + +``` + + +``` + +### Suggest country/state + +By using this function you'll make it easier for your visitor to input a country or state. + +``` +
+ ... +

+ Which country are you from? + +

+

+ Which state do you live in? + +

+
+ + + + +``` + +## File validators + +### File size + +This validation is only supported by Internet Explorer 10, Mozilla FireFox v >= 3.6 and any of the later versions of webkit based browsers. + +``` + + + + + +``` + +### File type + +This validation will fall back on checking the file extension in older browsers. In modern browsers the validation will check that any of the extensions in data-validation-allowing exists in the mime type declaration of the file. This means that data-validation-allowing="pdf" will work in both modern browsers (checking against "application/pdf") and older browsers (checking the file extension ".pdf"). + +``` + + + + + +``` + +Validating multiple files (with separate error messages depending on failed validation): + +``` + +``` + +### Image dimension and ratio + +Use the validator dimension to check the dimension of an image (jpg, gif or png). + +``` + + + + + + + + + + + + + + +``` + +Use the attribute data-validation-ratio to validate that the uploaded image has a certain ratio + +``` + + + + + +``` + + ## Changelog #### 2.3.19 From cac6a2790498bf13d12f21618706dcfb7b010f76 Mon Sep 17 00:00:00 2001 From: Victor Jonsson Date: Sat, 2 Feb 2019 09:09:20 +0100 Subject: [PATCH 4/4] Update README.md --- README.md | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d25e02..e1e957b 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ Read the documentation for the file module at [#file-validators](#file-validator * **Dependent validation** * **Require "one-of"** -Read the documentation for this module at [http://formvalidator.net/#logic](http://www.formvalidator.net/#logic) +Read the documentation for this module at [/#logic](#logic) ### Module: sepa @@ -875,6 +875,88 @@ Use the attribute data-validation-ratio to validate that the upload ``` +## Logic + +### Validators depending on each other + +Use the attributes data-validation-depends-on to configure that an input is optional as long as another input is left without an answer. + +``` + +

+ Contact me: + +

+

+ E-mail: + +

+``` + +``` + +

+ Country: + +

+ +

+ State: + +

+ +... + + + +``` + +### Require only one out of several inputs + +Use the attribute data-validation-optional-if-answered to tell the validator that only one, out of a group of inputs, requires an answer. + +``` +

+ Home phone number: + +

+

+ Cell phone number: + +

+

+ Work phone number: + +

+ +``` ## Changelog