我想比较电子邮件 ID。
当我在重复的电子邮件输入字段中输入电子邮件ID时,将进行验证
<form name ="myForm">
Email:<input name="emailid" type="email" ng-model="user.email" ng-required="true"/>
Repeat Email:<input type="email" name="emailRepeat" ng-model="email2" ng-required="true" ng-match="user.email">
<span ng-show="myForm.emailRepeat.$error.match">Emails have to match!</span><br><br>
<input type="submit" id="submit" value="Submit" /> or <input type="button" ng-click="cancelUserAdd()" value ="Cancel"/>.
</form>
角度中没有任何内置的东西可以做到这一点,但有一些库可以帮助你入门。
检查
https://github.com/TheSharpieOne/angular-input-match
或棱角分明的实用腰带
http://angular-ui.github.io/ui-utils/
或者你需要编写自己的验证器。
<p>Email:<input type="email" name="email1" ng-model="emailReg">
Repeat Email:<input type="email" name="email2" ng-model="emailReg2" ng-match="emailReg"></p>
<span data-ng-show="myForm.emailReg2.$error.match">Emails have to match!</span>
<input type="submit" id="submit" value="Submit" /> or <input type="button" ng-click="cancelUserAdd()" value ="Cancel"/>