forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.widget.@ng:validate.html
48 lines (46 loc) · 1.67 KB
/
angular.widget.@ng:validate.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<h1>angular.widget.@ng:validate</h1>
<fieldset class="workInProgress">
<legend>Work In Progress</legend>
This page is currently being revised. It might be incomplete or contain inaccuracies.
</fieldset>
<h2>Description</h2>
<p>The <code>ng:validate</code> attribute widget validates the user input. If the input does not pass
validation, the <code>ng-validation-error</code> CSS class and the <code>ng:error</code> attribute are set on the input
element. Check out <a href="#!angular.validator"><code>validators</code></a> to find out more.</p>
<h2>Usage</h2>
<h3>In HTML Template Binding</h3>
<tt>
<pre>
<INPUT @ng:validate="validator">
...
</INPUT>
</pre>
</tt>
<h3>Parameters</h3>
<ul>
<li><tt>validator</tt> –
<tt>{string}</tt>
<tt></tt>
– The name of a built-in or custom <a href="#!angular.validator"><code>validator</code></a> to
to be used.</li>
</ul>
<h3>CSS</h3>
ng-validation-error
<h2>Example</h2>
<p>This example shows how the input element becomes red when it contains invalid input. Correct
the input to make the error disappear.</p>
<doc:example>
<doc:source>
I don't validate:
<input type="text" name="value" value="NotANumber"><br/>
I need an integer or nothing:
<input type="text" name="value" ng:validate="integer"><br/>
</doc:source>
<doc:scenario> it('should check ng:validate', function(){
expect(element('.doc-example-live :input:last').attr('className')).
toMatch(/ng-validation-error/);
input('value').enter('123');
expect(element('.doc-example-live :input:last').attr('className')).
not().toMatch(/ng-validation-error/);
});</doc:scenario>
</doc:example>