我正在使用ngTagsInput
Angular插件獲取多個電子郵件ID。下面是我的代碼:ngTagsInput如何顯示不同情況下的驗證消息?
<form name="contact_us" role="form" novalidate enctype="multipart/form-data">
<div class="form-group">
<label class="control-label" for="from_email">
From
</label>
<tags-input ng-model="contactUs.emails" type="email" id="from_email"
placeholder="From" name="from_email"
allowed-tags-pattern="^[A-Za-z0-9._%+-][email protected](?:[A-Za-z0-9-]+.)+[A-Za-z]{2,}"
allow-leftover-text="false" ng-required="true" add-on-space="true">
</tags-input>
<p class="help-block" style="color:red"
ng-show="contact_us.from_email.$invalid && (contact_us.$submitted || contact_us.$dirty)">
Please enter proper email address
</p>
<button type="submit" class="btn btn-default" ng-click="Send(contact_us)">
Send
</button>
</form>
在上面的代碼3驗證已添加那些如下:
- 強制字段。
- 該字段只能接受電子郵件ID。
- 它不應該允許重複的電子郵件ID。
上述案例工作正常。但是,我想根據上述發生的情況動態顯示錯誤消息。請幫助我!
ngTagsInput插件不支持NG-change.Please讓我知道,這是任何其他方式來顯示不同驗證方法 – manisankar