【问题标题】:How to compare email id in angularjs form submit如何在angularjs表单提交中比较电子邮件ID
【发布时间】:2015-03-22 11:41:55
【问题描述】:

我想比较电子邮件 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> 

【问题讨论】:

    标签: angularjs validation compare email-validation


    【解决方案1】:

    没有任何内置的 Angular 可以做到这一点,但有一些库可以帮助您入门。

    检查

    https://github.com/TheSharpieOne/angular-input-match

    或 angular-ui 实​​用腰带

    http://angular-ui.github.io/ui-utils/

    或者您需要编写自己的验证器。

    【讨论】:

      【解决方案2】:
      <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"/>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-11-05
        • 2011-10-12
        • 2013-09-16
        • 2017-02-09
        • 2014-09-30
        • 2016-08-01
        相关资源
        最近更新 更多