我有一个带有两个输入的表格,电子邮件和电话号码
要提交表单,有一个Button,默认为diaged
知道我的愿望是,当其中一个字段被正确填充时,按钮就会启用。
这是我的意见:
<input
type="email"
ng-model="userEmail"
class="form-control input-lg"
ng-class="{error: successEmailForm.sendFeedbackMail.$invalid && successEmailForm.sendFeedbackMail.$dirty}"
id="sendFeedbackMail"
name="sendFeedbackMail"
placeholder="E-Mail"
required> // only one of two should be required
<input
type="number"
ng-model="userPhone"
class="form-control input-lg"
ng-class="{error: successEmailForm.sendFeedbackPhone.$invalid && successEmailForm.sendFeedbackPhone.$dirty}"
id="sendFeedbackPhone"
placeholder="TELEFON"
id="sendFeedbackPhone"
required
>
<a type="button"
class="btn btn-default btn-block btn-lg btn-green upper"
id="successEmailBtn"
ng-disabled="successEmailForm.sendFeedbackMail.$error.email || successEmailForm.sendFeedbackMail.$error.required || successEmailForm.sendFeedbackPhone.$required"
ng-click="postSuccess()"
href=""
>
有没有人知道这是如何起作用的? THX
答案 0 :(得分:2)
在ng-disabled指令中添加一个简单表达式,以检查电子邮件和手机型号值:
ng-disabled='!userEmail && !userPhone'