mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-21 04:41:51 +00:00
docs(overview): correct the input validation example
The documentation says that the input should be red if you enter invalid values or leave it blank. Because the type="integer" is not supported this does not happen in practice. This fix changes the input type to number and adds an ng-pattern to ensure that the number is an integer.
This commit is contained in:
parent
a7d081fac0
commit
3508f76719
1 changed files with 2 additions and 2 deletions
|
|
@ -90,7 +90,7 @@ concepts which the application developer may face:
|
||||||
<table>
|
<table>
|
||||||
<tr><td>Quantity</td><td>Cost</td></tr>
|
<tr><td>Quantity</td><td>Cost</td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><input type="integer" min="0" ng-model="qty" required ></td>
|
<td><input type="number" ng-pattern="/\d+/" step="1" min="0" ng-model="qty" required ></td>
|
||||||
<td><input type="number" ng-model="cost" required ></td>
|
<td><input type="number" ng-model="cost" required ></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
@ -124,7 +124,7 @@ We load Angular using the `<script>` tag:
|
||||||
From the `ng-model` attribute of the `<input>` tags, Angular automatically sets up two-way data
|
From the `ng-model` attribute of the `<input>` tags, Angular automatically sets up two-way data
|
||||||
binding, and we also demonstrate some easy input validation:
|
binding, and we also demonstrate some easy input validation:
|
||||||
|
|
||||||
Quantity: <input type="integer" min="0" ng-model="qty" required >
|
Quantity: <input type="number" ng-pattern="/\d+/" step="1" min="0" ng-model="qty" required >
|
||||||
Cost: <input type="number" ng-model="cost" required >
|
Cost: <input type="number" ng-model="cost" required >
|
||||||
|
|
||||||
These input widgets look normal enough, but consider these points:
|
These input widgets look normal enough, but consider these points:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue