Skip to content

Commit b20a01c

Browse files
committed
Major content update, porting more mediawiki content. Apart from plenty of proofreading, only methods remain to port.
1 parent 4b34720 commit b20a01c

20 files changed

+967
-1848
lines changed

DEPRECATED

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Redirect these to the API documentation page:
2+
3+
jQuery.fn.removeAttrs
4+
Validator.refresh

categories.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
Methods available on the Validator object returned by the validate method.
1313
]]></desc>
1414
</category>
15+
<category name="Selectors" slug="selectors"/>
1516
</categories>

entries/Validator.addClassRules.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0"?>
2+
<?xml-stylesheet type="text/xsl" href="../entries2html.xsl" ?>
3+
<entry type="method" name="Validator.addClassRules">
4+
<title>Validator.addClassRules()</title>
5+
<signature>
6+
<argument name="name" type="String">
7+
<desc>The name of the class rule to add</desc>
8+
</argument>
9+
<argument name="rules" type="Object">
10+
<desc>The compound rules (see example)</desc>
11+
</argument>
12+
</signature>
13+
<signature>
14+
<argument name="rules" type="Object">
15+
<desc>A map of className-rules pairs (see example).</desc>
16+
</argument>
17+
</signature>
18+
<desc>Add a compound class method - useful to refactor common combinations of rules into a single class.</desc>
19+
<example>
20+
<desc>Add a new compound rule called "name", replacing class="required" minlength="2" with class="name".</desc>
21+
<code><![CDATA[
22+
jQuery.validator.addClassRules("name", {
23+
required: true,
24+
minlength: 2
25+
});
26+
]]></code>
27+
</example>
28+
<example>
29+
<desc>Add two compound class rules for name and zip.</desc>
30+
<code><![CDATA[
31+
jQuery.validator.addClassRules({
32+
name: {
33+
required: true,
34+
minlength: 2
35+
},
36+
zip: {
37+
required: true,
38+
digits: true,
39+
minlength: 5,
40+
maxlength: 5
41+
}
42+
});
43+
]]></code>
44+
</example>
45+
<category slug="validator"/>
46+
</entry>

entries/Validator.element.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<?xml-stylesheet type="text/xsl" href="../entries2html.xsl" ?>
3+
<entry type="method" name="Validator.element">
4+
<title>Validator.element()</title>
5+
<signature>
6+
<argument name="element" type="Selector">
7+
<desc>An element to validate, must be inside the validated form.</desc>
8+
</argument>
9+
</signature>
10+
<desc>Validates a single element, returns true if it is valid, false otherwise.</desc>
11+
<longdesc>This behaves as validation on blur or keyup, but returns the result.</longdesc>
12+
<example>
13+
<desc>Triggers element validation programmatically.</desc>
14+
<code><![CDATA[
15+
var validator = $( "#myform" );
16+
validator.element( "#myselect" );
17+
]]></code>
18+
</example>
19+
<category slug="validator"/>
20+
</entry>

entries/Validator.form.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="Validator.form">
4+
<title>Validator.form()</title>
5+
<signature>
6+
</signature>
7+
<desc>Validates the form, returns true if it is valid, false otherwise.</desc>
8+
<longdesc>This behaves as a normal submit event, but returns the result.</longdesc>
9+
<example>
10+
<desc>Triggers form validation programmatically.</desc>
11+
<code><![CDATA[
12+
var validator = $( "#myform" );
13+
validator.form();
14+
]]></code>
15+
</example>
16+
<category slug="validator"/>
17+
</entry>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<?xml-stylesheet type="text/xsl" href="../entries2html.xsl" ?>
3+
<entry type="method" name="Validator.numberOfInvalids" returns="Number">
4+
<title>Validator.numberOfInvalids()</title>
5+
<signature>
6+
<argument name="errors" type="Object">
7+
<desc>One or more key/value pairs of input names and messages.</desc>
8+
</argument>
9+
</signature>
10+
<desc>Returns the number of invalid fields.</desc>
11+
<longdesc>This depends on the internal validator state. It covers all fields only after validating the complete form (on submit or via $("form").valid()). After validating a single element, only that element is counted. Most useful in combination with the invalidHandler-option.</longdesc>
12+
<example>
13+
<desc>Displays a summary of invalid fields after a invalid submit.</desc>
14+
<code><![CDATA[
15+
var validator = $( "#myform" ).validate({
16+
invalidHandler: function() {
17+
$( "#summary" ).text( validator.numberOfInvalids() + " field(s) are invalid" );
18+
}
19+
});
20+
]]></code>
21+
</example>
22+
<category slug="validator"/>
23+
</entry>

entries/Validator.showErrors.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0"?>
2+
<?xml-stylesheet type="text/xsl" href="../entries2html.xsl" ?>
3+
<entry type="method" name="Validator.showErrors">
4+
<title>Validator.showErrors()</title>
5+
<signature>
6+
<argument name="errors" type="Object">
7+
<desc>One or more key/value pairs of input names and messages.</desc>
8+
</argument>
9+
</signature>
10+
<desc>Show the specified messages.</desc>
11+
<longdesc>Keys have to refer to the names of elements, values are displayed for those elements, using the configured error placement.</longdesc>
12+
<example>
13+
<desc>Adds and shows error message programmatically.</desc>
14+
<code><![CDATA[
15+
var validator = $( "#myshowErrors" );
16+
validator.showErrors({
17+
"firstname": "I know that your firstname is Pete, Pete!"
18+
});
19+
]]></code>
20+
</example>
21+
<category slug="validator"/>
22+
</entry>

entries/blank-selector.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<entry type="selector" name="blank" return="">
3+
<title>:blank Selector</title>
4+
<sample>:blank</sample>
5+
<signature>
6+
<added>1.0</added>
7+
</signature>
8+
<desc>Selects all elements with a blank value.</desc>
9+
<longdesc>
10+
Blank means either no value at all or only whitespace.
11+
<p>The implementation does a check like this: <code>jQuery.trim(value).length == 0</code></p>
12+
</longdesc>
13+
<example>
14+
<desc>Finds input elements with no value or just whitespace.</desc>
15+
<code><![CDATA[
16+
$( "input:blank" ).css( "background-color", "#bbbbff" );
17+
]]></code>
18+
<html><![CDATA[
19+
<div>Mouseover to see the value of each input</div>
20+
<input value="" title='""'>
21+
<input value=" " title='" "'>
22+
<input value="abc" title='"abc"'>
23+
]]></html>
24+
</example>
25+
<category slug="selectors"/>
26+
</entry>

entries/filled-selector.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<entry type="selector" name="filled" return="">
3+
<title>:filled Selector</title>
4+
<sample>:filled</sample>
5+
<signature>
6+
<added>1.0</added>
7+
</signature>
8+
<desc>Selects all elements with a filled value.</desc>
9+
<longdesc>
10+
filled means any value, but not only whitespace.
11+
<p>The implementation does a check like this: <code>jQuery.trim(value).length &gt; 0</code></p>
12+
</longdesc>
13+
<example>
14+
<desc>Finds input elements with a non-whitespace value.</desc>
15+
<code><![CDATA[
16+
$( "input:filled" ).css( "background-color", "#bbbbff" );
17+
]]></code>
18+
<html><![CDATA[
19+
<div>Mouseover to see the value of each input</div>
20+
<input value="" title='""'>
21+
<input value=" " title='" "'>
22+
<input value="abc" title='"abc"'>
23+
]]></html>
24+
</example>
25+
<category slug="selectors"/>
26+
</entry>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0"?>
2+
<?xml-stylesheet type="text/xsl" href="../entries2html.xsl" ?>
3+
<entry type="method" name="jQuery.validator.addMethod">
4+
<title>jQuery.validator.addMethod()</title>
5+
<signature>
6+
<argument name="name" type="String">
7+
<desc>The name of the method, used to identify and referencing it, must be a valid javascript identifier</desc>
8+
</argument>
9+
<argument name="method" type="Function">
10+
<desc>The actual method implementation, returning true if an element is valid. First argument: Current value. Second argument: Validated element. Third argument: Parameters.</desc>
11+
<property name="value" type="String">
12+
<desc>the current value of the validated element</desc>
13+
</property>
14+
<property name="element" type="Element">
15+
<desc>the element to be validated</desc>
16+
</property>
17+
<property name="value" type="String">
18+
<desc>parameters specified for the method, e.g. for min: 5 the parameter is 5, for range: [1, 5] its [1, 5]</desc>
19+
</property>
20+
</argument>
21+
<argument name="message" type="String" optional="true">
22+
<desc>The default message to display for this method. Can be a function created by ''jQuery.validator.format(value)''. When undefined, an already existing message is used (handy for localization), otherwise the field-specific messages have to be defined.</desc>
23+
</argument>
24+
</signature>
25+
<desc>Add a custom validation method. It must consist of a name (must be a legal javascript identifier), a javascript based function and a default string message.</desc>
26+
<longdesc>The arguments to the callback are:
27+
* the current value of the validated element
28+
* the element to be validated
29+
* parameters specified for the method, e.g. for min: 5 the parameter is 5, for range: [1, 5] its [1, 5]
30+
31+
Please note: While the temptation is great to add a regex method that checks it's parameter against the value, it is much cleaner to encapsulate those regular expressions inside their own method. If you need lots of slightly different expressions, try to extract a common parameter.
32+
33+
See also a <a href="http://regexlib.com/DisplayPatterns.aspx">library of regular expressions</a>.
34+
</longdesc>
35+
<example>
36+
<desc>Add a validation method that checks if a value starts with a certain domain.</desc>
37+
<code><![CDATA[
38+
jQuery.validator.addMethod("domain";, function(value, element) {
39+
return this.optional(element) || /^http:\/\/mycorporatedomain.com/.test(value);
40+
}, "Please specify the correct domain for your documents");
41+
]]></code>
42+
</example>
43+
<example>
44+
<desc>Adds a validation method that checks if a given value equals the addition of the two parameters.</desc>
45+
<code><![CDATA[
46+
jQuery.validator.addMethod("math", function(value, element, params) {
47+
return this.optional(element) || value == params[0] + params[1];
48+
}, jQuery.validator.format("Please enter the correct value for {0} + {1}"));
49+
]]></code>
50+
</example>
51+
<category slug="validator"/>
52+
</entry>

entries/jQuery.validator.format.xml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0"?>
2+
<?xml-stylesheet type="text/xsl" href="../entries2html.xsl" ?>
3+
<entry type="method" name="jQuery.validator.format" returns="Function">
4+
<title>jQuery.validator.format()</title>
5+
<signature>
6+
<argument name="template" type="String">
7+
<desc>The string to format.</desc>
8+
</argument>
9+
<argument name="argument" type="Object">
10+
<desc>The first argument to insert, or an array of Strings to insert</desc>
11+
</argument>
12+
<argument name="argumentN..." type="Object">
13+
<desc>The second etc. argument to insert</desc>
14+
</argument>
15+
</signature>
16+
<desc>Replaces {n} placeholders with arguments.</desc>
17+
<longdesc>
18+
One or more arguments can be passed, in addition to the string template itself, to insert into the string.
19+
<p>If you're familiar with the term, this makes this function support currying. If you don't care about that, just use the first argument.</p>
20+
</longdesc>
21+
<example>
22+
<desc>Sets the debug setting for all validation calls.</desc>
23+
<code><![CDATA[
24+
var template = jQuery.validator.format("{0} is not a valid value");
25+
// later, results in 'abc is not a valid value'
26+
alert(template("abc"));
27+
]]></code>
28+
</example>
29+
<!-- {{APIExample|
30+
|desc=Demonstrates basic usage.
31+
|code=&lt;nowiki&gt;
32+
$(&quot;button&quot;).&lt;/nowiki&gt;{{Code|Events|click}}&lt;nowiki&gt;(function () {
33+
var str = &quot;Hello {0}, this is {1}&quot;;
34+
alert(&quot;'&quot; + str + &quot;'&quot;);
35+
36+
str = &lt;/nowiki&gt;{{Code|Plugins/Validation|jQuery.validator.format}}&lt;nowiki&gt;(str, &quot;World&quot;, &quot;Bob&quot;);
37+
alert(&quot;'&quot; + str + &quot;'&quot;);
38+
});
39+
&lt;/nowiki&gt;
40+
|inhead=&lt;nowiki&gt;&lt;script src=&quot;http://jzaefferer.github.com/jquery-validation/jquery.validate.js&quot;&gt;&lt;/script&gt;&lt;/nowiki&gt;
41+
|html=&lt;nowiki&gt;&lt;button&gt;Show format Example&lt;/button&gt;&lt;/nowiki&gt;
42+
}}
43+
44+
{{APIExample|
45+
|desc=Shows how to first create a template function by passing only the string argument and then calling it later.
46+
|code=&lt;nowiki&gt;$(&quot;button&quot;).&lt;/nowiki&gt;{{Code|Events|click}}&lt;nowiki&gt;(function () {
47+
var template = &lt;/nowiki&gt;{{Code|Plugins/Validation|jQuery.validator.format}}&lt;nowiki&gt;(&quot;Please enter more {0}, or order {0} by mail (see {1})&quot;);
48+
alert(template(&quot;Apples&quot;, &quot;our FAQ&quot;));
49+
});
50+
&lt;/nowiki&gt;
51+
|inhead=&lt;nowiki&gt;&lt;script src=&quot;http://jzaefferer.github.com/jquery-validation/jquery.validate.js&quot;&gt;&lt;/script&gt;&lt;/nowiki&gt;
52+
|html=&lt;nowiki&gt;&lt;button&gt;Show format Example&lt;/button&gt;&lt;/nowiki&gt;
53+
}} -->
54+
<category slug="validator"/>
55+
</entry>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
<?xml-stylesheet type="text/xsl" href="../entries2html.xsl" ?>
3+
<entry type="method" name="jQuery.validator.setDefaults">
4+
<title>jQuery.validator.setDefaults()</title>
5+
<signature>
6+
<argument name="options" type="Object">
7+
<desc>Options to set as default.</desc>
8+
</argument>
9+
</signature>
10+
<desc>Modify default settings for validation.</desc>
11+
<longdesc>Accepts everything that <a href="/validate">validate()</a> accepts.</longdesc>
12+
<example>
13+
<desc>Sets the debug setting for all validation calls.</desc>
14+
<code><![CDATA[
15+
jQuery.validator.setDefaults({
16+
debug: true
17+
});
18+
]]></code>
19+
</example>
20+
<category slug="validator"/>
21+
</entry>

0 commit comments

Comments
 (0)