You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-67Lines changed: 16 additions & 67 deletions
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ So what has changed since version 1.x?
45
45
* You no longer need to prefix the validation rules with "validate_".
46
46
* Error message position now defaults to "element".
47
47
* 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.
49
49
50
50
51
51
### Default validators and features (no module needed)
@@ -67,21 +67,21 @@ So what has changed since version 1.x?
67
67
data-validation-if-checked="name of checkbox input"
68
68
* Create input suggestions with ease, no jquery-ui needed
69
69
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)
71
71
72
72
### Module: security
73
73
***spamcheck**
74
74
***confirmation**
75
75
***strength** — *Validate the strength of a password (strength strength3)*
76
76
***backend** — *Validate value of input on backend*
77
77
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)
79
79
80
80
### Module: date
81
81
***time** — *hh:mm*
82
82
***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)*
83
83
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)
85
85
86
86
### Module: location
87
87
***country**
@@ -90,7 +90,7 @@ Read the documentation for the [date module at http://formvalidator.net/#default
90
90
* Suggest countries (english only)
91
91
* Suggest states in the US
92
92
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)
94
94
95
95
### Module: sweden
96
96
***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
100
100
* Suggest county
101
101
* Suggest municipality
102
102
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)
104
104
105
105
### Module: uk
106
106
***ukvatnumber**
107
107
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)
109
109
110
110
111
111
## Writing a custom validator
@@ -148,7 +148,7 @@ that checks if the input contains an even number.
148
148
*errorMessageKey* - Name of language property that is used in case the value of the input is invalid.
149
149
150
150
*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.
152
152
153
153
154
154
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
192
192
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.
<textareaname="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
201
201
```
202
202
203
203
## 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,
235
204
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)
254
206
255
207
## Localization
256
208
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 = {
300
252
...
301
253
```
302
254
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.
304
257
305
258
## Input length restriction
306
259
```html
@@ -313,19 +266,15 @@ Inline error messages is also possible. If you add attribute data-validation-err
313
266
</script>
314
267
```
315
268
316
-
## Password confirmation example
317
-
318
-
[Click here for more info](http://formvalidator.net/#security-validators_confirmation)
319
-
320
269
## Changelog
321
270
322
271
#### 2.0
323
272
*[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
325
274
* 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)
329
278
* Some validation functions is moved to modules (see function reference in top of this document)
330
279
* Added function $.formSetup() to reduce the amount of code that has to be written when initiating the form validation.
0 commit comments