Skip to content

Commit 40afccf

Browse files
committed
added documentation
1 parent 882181c commit 40afccf

File tree

1 file changed

+16
-67
lines changed

1 file changed

+16
-67
lines changed

README.md

Lines changed: 16 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ So what has changed since version 1.x?
4545
* You no longer need to prefix the validation rules with "validate_".
4646
* Error message position now defaults to "element".
4747
* The optional features (validateOnBlur and showHelpOnFocus) is now enabled by default.
48-
* The function $.setupForm(config) is introduced to reduce the amount of code that needs to be written when initiating the form validation.
48+
* The function $.setupForm(config) is introduced to reduce the amount of code that has to be written when initiating the form validation.
4949

5050

5151
### Default validators and features (no module needed)
@@ -67,21 +67,21 @@ So what has changed since version 1.x?
6767
data-validation-if-checked="name of checkbox input"
6868
* Create input suggestions with ease, no jquery-ui needed
6969

70-
Read the documentation for the [default features at http://formvalidator.net/##default-validators](http://formvalidator.net/#default-validators)
70+
Read the documentation for the default features at [http://formvalidator.net/#default-validators](http://formvalidator.net/#default-validators)
7171

7272
### Module: security
7373
* **spamcheck**
7474
* **confirmation**
7575
* **strength***Validate the strength of a password (strength strength3)*
7676
* **backend***Validate value of input on backend*
7777

78-
Read the documentation for the [security module at http://formvalidator.net/#default-validators](http://formvalidator.net/#security-validators)
78+
Read the documentation for the security module at [http://formvalidator.net/#security-validators](http://formvalidator.net/#security-validators)
7979

8080
### Module: date
8181
* **time***hh:mm*
8282
* **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)*
8383

84-
Read the documentation for the [date module at http://formvalidator.net/#default-validators](http://formvalidator.net/#date-validators)
84+
Read the documentation for the date module at [http://formvalidator.net/#date-validators](http://formvalidator.net/#date-validators)
8585

8686
### Module: location
8787
* **country**
@@ -90,7 +90,7 @@ Read the documentation for the [date module at http://formvalidator.net/#default
9090
* Suggest countries (english only)
9191
* Suggest states in the US
9292

93-
Read the documentation for the [location module at http://formvalidator.net/#default-validators](http://formvalidator.net/#location-validators)
93+
Read the documentation for the location module at [http://formvalidator.net/#location-validators](http://formvalidator.net/#location-validators)
9494

9595
### Module: sweden
9696
* **swemob***validate that the value is a swedish mobile telephone number*
@@ -100,12 +100,12 @@ Read the documentation for the [location module at http://formvalidator.net/#def
100100
* Suggest county
101101
* Suggest municipality
102102

103-
Read the documentation for the [Swedish module at http://formvalidator.net/#default-validators](http://formvalidator.net/#sweden-validators)
103+
Read the documentation for the Swedish module at [http://formvalidator.net/#sweden-validators](http://formvalidator.net/#sweden-validators)
104104

105105
### Module: uk
106106
* **ukvatnumber**
107107

108-
Read the documentation for the [UK module at http://formvalidator.net/#default-validators](http://formvalidator.net/#uk-validators)
108+
Read the documentation for the UK module at [http://formvalidator.net/#uk-validators](http://formvalidator.net/#uk-validators)
109109

110110

111111
## Writing a custom validator
@@ -148,7 +148,7 @@ that checks if the input contains an even number.
148148
*errorMessageKey* - Name of language property that is used in case the value of the input is invalid.
149149

150150
*errorMessage* - An alternative error message that is used if errorMessageKey is left with an empty value or isn't defined
151-
in the language object. Note that you also can use [inline error messages](#localization) in your form.
151+
in the language object. Note that you also can use [inline error messages](http://formvalidator.net/#localization) in your form.
152152

153153

154154
The validation function takes these five arguments:
@@ -192,7 +192,7 @@ the module files has to be located in the same directory as the core modules shi
192192
It is possible to display help information for each input. The information will fade in when input is focused and fade out when input looses focus.
193193

194194
```html
195-
<form action="" onsubmit="return $(this).validate();" id="my_form">
195+
<form action="" id="my_form">
196196
<p>
197197
<strong>Why not:</strong>
198198
<textarea name="why" data-validation-help="Please give us some more information" data-validation="required"></textarea>
@@ -201,56 +201,8 @@ It is possible to display help information for each input. The information will
201201
```
202202

203203
## Fully customizable
204-
```javascript
205-
var myConf = {
206-
// Name of element attribute holding the validation rules (default is data-validation)
207-
validationRuleAttribute : 'class',
208-
209-
// Names of inputs not to be validated even though the element attribute containing
210-
// the validation rules tells us to
211-
ignore : ['som-name', 'other-name'],
212-
213-
// Class that will be put on elements which value is invalid (default is 'error')
214-
errorElementClass : 'error',
215-
216-
// Border color of elements which value is invalid, empty string to leave border
217-
// color as it is
218-
borderColorOnError : '#FFF',
219-
220-
// Class of div container showing error messages (defualt is 'error_message')
221-
errorMessageClass : 'error_message',
222-
223-
// Position of error messages. Set the value to "top" if you want the error messages
224-
// to be displayed in the top of the form. Otherwise you can set the value to
225-
// "element", each error message will then be displayed beside the input field that
226-
// it is refering to (default is 'element')
227-
errorMessagePosition : 'top',
228-
229-
// Date format used when validating dates and birthdate. (default is yyyy-mm-dd)
230-
dateFormat : 'dd/mm/yyyy',
231-
232-
// Window automatically scrolls to the top of the form when submitted data is
233-
// invalid (default is true)
234-
scrollToTopOnError : false,
235204

236-
// Name of the element attribute containing the error message that will be
237-
// displayed instead of the error dialog that the validation function
238-
// referrs to (default is data-validation-error-msg)
239-
validationErrorMsgAttribute : 'data-error'
240-
};
241-
242-
var myLang = {
243-
errorTitle : 'Något gick fel',
244-
requiredFields : 'Du fyllde inte i alla fält markerade med *'
245-
};
246-
247-
$('#my_form')
248-
.showHelpOnFocus()
249-
.validateOnBlur(myLang, myConf)
250-
.submit(function() {
251-
return $(this).validate(myLang, myConf);
252-
});
253-
```
205+
Read about how to customize this plugin over at [http://formvalidator.net/#configuration](http://formvalidator.net/#configuration)
254206

255207
## Localization
256208
This plugin contains a set of error dialogs. In case you don't define an inline error message the plugin
@@ -300,7 +252,8 @@ var enErrorDialogs = {
300252
...
301253
```
302254

303-
Inline error messages is also possible. If you add attribute data-validation-error-msg to an element the value of that attribute will be displayed instead of the error dialog that the validation function refers to.
255+
Inline error messages is also possible. If you add attribute `data-validation-error-msg` to an element the value of
256+
that attribute will be displayed instead of the error dialog that the validation function refers to.
304257

305258
## Input length restriction
306259
```html
@@ -313,19 +266,15 @@ Inline error messages is also possible. If you add attribute data-validation-err
313266
</script>
314267
```
315268

316-
## Password confirmation example
317-
318-
[Click here for more info](http://formvalidator.net/#security-validators_confirmation)
319-
320269
## Changelog
321270

322271
#### 2.0
323272
* [min|max]_length is removed (now merged with length)
324-
* number, int, float is merged together, all three variants is now validated by number
273+
* number, int, float is merged together, all three variants is now validated by the number validation
325274
* phone moved to "sweden" module and renamed to swephone
326-
* The attribute to be used when defining the regular expression for custom is now moved to its own attribute (data-validation-regexp)
327-
* length now looks at attribute data-validation-length to find out how long or short the value must be
328-
* The validation rule no longer needs to be prefixed with ""
275+
* The attribute to be used when defining the regular expression for custom validations is now moved to its own attribute (data-validation-regexp)
276+
* Length validation now looks at attribute data-validation-length to find out how long or short the value must be
277+
* The validation rule no longer needs to be prefixed with "validate_" (it's still possible to use the prefix but it's considered deprecated)
329278
* Some validation functions is moved to modules (see function reference in top of this document)
330279
* Added function $.formSetup() to reduce the amount of code that has to be written when initiating the form validation.
331280

0 commit comments

Comments
 (0)