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: pages/reference.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ The ultimate goal of this plugin is to make working with forms more fun for ever
7
7
8
8
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.
9
9
10
-
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.
10
+
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.
11
11
12
12
# Markup recommendations
13
13
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.
@@ -20,7 +20,7 @@ Optionally: Each input can have a label associated with it, where the 'for' attr
20
20
```
21
21
22
22
# Methods
23
-
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 <ahref="/jQuery.validator.addMethod/">jQuery.validator.addMethod</a> to implement custom methods.
23
+
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 <ahref="/jQuery.validator.addMethod/">jQuery.validator.addMethod</a> to implement custom methods.
24
24
25
25
# Rules
26
26
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.
@@ -42,7 +42,7 @@ If your form consists of fields using names that aren't legal JavaScript identif
42
42
```
43
43
44
44
## Refactoring rules
45
-
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.
45
+
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.
46
46
47
47
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:
48
48
@@ -66,7 +66,7 @@ With that in place, we can add a class customer to all customer fields and be do
66
66
<inputname="customer3"class="customer">
67
67
```
68
68
69
-
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:
69
+
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:
@@ -82,7 +82,7 @@ The priorities are as follows: A custom message (passed by plugin options), the
82
82
When using data attributes, you can set a generic message for all rules, or specific messages per rule:
83
83
```html
84
84
<inputrequireddata-msg="Please fill this field">
85
-
<inputdata-rule-minlength="2"data-rule-maxlength="4"data-msg-minlength="At least two chars"data-msg-maxlength="At most fours chars">
85
+
<inputdata-rule-minlength="2"data-rule-maxlength="4"data-msg-minlength="At least two chars"data-msg-maxlength="At most four chars">
86
86
```
87
87
88
88
# Error message display
@@ -98,7 +98,7 @@ By default, the first invalid element in a form is focused after submitting a fo
98
98
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`).
99
99
100
100
## Skipping validation on submit
101
-
To skip validation while still using a submit-button, add the attribte "formnovalidate" to that input:
101
+
To skip validation while still using a submit-button, add the attribute "formnovalidate" to that input:
0 commit comments