Skip to content

Commit bbdb572

Browse files
committed
Entries: Promote jQuery.validator.methods property as public api
Includes a example which shows how to make built-in email validation use a custom email regular expression pattern.
1 parent add4f75 commit bbdb572

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

entries/jQuery.validator.methods.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<?xml-stylesheet type="text/xsl" href="../entries2html.xsl" ?>
3+
<entry type="method" name="jQuery.validator.methods" returns="Object">
4+
<title>jQuery.validator.methods</title>
5+
<desc>
6+
Object holding all validation methods known to the validator.
7+
This can be accessed to override individual methods, while keeping the default messages.</desc>
8+
<example>
9+
<desc>Sets a custom email pattern for the built-in email validation rule.</desc>
10+
<code><![CDATA[
11+
$.validator.methods.email = function( value, element ) {
12+
return this.optional( element ) || /[a-z]+@[a-z]+\.[a-z]+/.test( value );
13+
}
14+
]]></code>
15+
</example>
16+
<category slug="validator"/>
17+
</entry>

pages/documentation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ Some more methods are provided as add-ons, and are currently included in additio
133133

134134
You can find the [source code for all additional methods in the GitHub repository](https://github.com/jzaefferer/jquery-validation/tree/master/src/additional).
135135

136+
It is possible to re-define the implementation of the built-in rules using the [$.validator.methods property](/jQuery.validator.methods/)
137+
136138
# [General Guidelines](/reference)
137139

138140
The General Guidelines section provides detailed discussion of the design and ideas behind the plugin, explaining why certain things are as they are. It covers the features in more detail than the API documentation, which just briefly explains the various methods and options available.

0 commit comments

Comments
 (0)