Skip to content

Commit d109035

Browse files
Arknistaabm
authored andcommitted
Readme: Add note about trimming whitespaces inside required method
1 parent 16227e4 commit d109035

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ See the [Contributing Guidelines](CONTRIBUTING.md) for details.
5151

5252
**IMPORTANT NOTE ABOUT EMAIL VALIDATION**. As of version 1.12.0 this plugin is using the same regular expression that the [HTML5 specification suggests for browsers to use](https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address). We will follow their lead and use the same check. If you think the specification is wrong, please report the issue to them. If you have different requirements, consider [using a custom method](https://jqueryvalidation.org/jQuery.validator.addMethod/).
5353
In case you need to adjust the built-in validation regular expression patterns, please [follow the documentation](https://jqueryvalidation.org/jQuery.validator.methods/).
54+
**IMPORTANT NOTE ABOUT REQUIRED METHOD**. As of version 1.14.0 this plugin stops trimming white spaces from the value of the attached element. If you want to achieve the same result, you can use the [`normalizer`](https://jqueryvalidation.org/normalizer/) that can be used to transform the value of an element before validation. This feature was available since `v1.15.0`. In other words, you can do something like this:
55+
``` js
56+
$("#myForm").validate({
57+
rules: {
58+
username: {
59+
required: true,
60+
// Using the normalizer to trim the value of the element
61+
// before validating it.
62+
//
63+
// The value of `this` inside the `normalizer` is the corresponding
64+
// DOMElement. In this example, `this` references the `username` element.
65+
normalizer: function(value) {
66+
return $.trim(value);
67+
}
68+
}
69+
}
70+
});
71+
```
5472

5573
## License
5674
Copyright &copy; Jörn Zaefferer<br>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy