参考:http://www.cnblogs.com/rohelm/p/4033513.html

1. 必填项验证

<input type="text" required />  

2. 最小/大长度

<input type="text" ng-minlength="5" ng-maxlength="10"/>

3.模式匹配

<input type="text" ng-pattern="/[a-zA-Z]/" />

4.电子邮件

<input type="email" name="email" ng-model="user.email" />

5.数字

<input type="number" name="age" ng-model="user.age" />

6.URL

<input type="url" name="homepage" ng-model="user.facebook_url" />

 实例一:

ng表单验证

 实例二:

CSS 类

ng-model 指令基于它们的状态为 HTML 元素提供了 CSS 类:

ng表单验证

 

ng-model 指令根据表单域的状态添加/移除以下类:

  • ng-empty
  • ng-not-empty
  • ng-touched
  • ng-untouched
  • ng-valid
  • ng-invalid
  • ng-dirty
  • ng-pending
  • ng-pristine

 

相关文章:

猜你喜欢
  • 2022-01-31
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
相关资源
相似解决方案