Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 如何在所有字段都有效之前禁用“提交”按钮_Angularjs - Fatal编程技术网

Angularjs 如何在所有字段都有效之前禁用“提交”按钮

Angularjs 如何在所有字段都有效之前禁用“提交”按钮,angularjs,Angularjs,目前,我知道如何为每个字段设置验证 但我不知道如何在所有字段都有效之前禁用提交按钮 <div class="form-group"> <label>Name</label> <span ng-messages="form.name.$error" class="alert"> <span ng-message="required">{{I18n.t("required_field_could_not_be

目前,我知道如何为每个字段设置验证

但我不知道如何在所有字段都有效之前禁用提交按钮

<div class="form-group">
    <label>Name</label>
    <span ng-messages="form.name.$error" class="alert">
        <span ng-message="required">{{I18n.t("required_field_could_not_be_empty")}}</span>
    </span>
    <input type="text" class="form-control" ng-model="payment_contact.name" required="required" name="name">
</div>

....

   <label>Email</label>
    <span ng-class="{'alert':form.email_booking.$error.email}" ng-show="form.email_booking.$error.email" >
    {{I18n.t("invalid_format")}}
    </span>
    <input type="email" id="email_booking" name="email_booking" class="form-control" ng-model="payment_contact.email">
</div>                            

<a ng-click="place_order()" class="btn_1 green medium">Book now</a>
并在所有字段有效后启用“提交”按钮

<div class="form-group">
    <label>Name</label>
    <span ng-messages="form.name.$error" class="alert">
        <span ng-message="required">{{I18n.t("required_field_could_not_be_empty")}}</span>
    </span>
    <input type="text" class="form-control" ng-model="payment_contact.name" required="required" name="name">
</div>

....

   <label>Email</label>
    <span ng-class="{'alert':form.email_booking.$error.email}" ng-show="form.email_booking.$error.email" >
    {{I18n.t("invalid_format")}}
    </span>
    <input type="email" id="email_booking" name="email_booking" class="form-control" ng-model="payment_contact.email">
</div>                            

<a ng-click="place_order()" class="btn_1 green medium">Book now</a>

名称
{{I18n.t(“必填字段不能为空”)}
....
电子邮件
{{I18n.t(“无效的_格式”)}
现在预订

由于表单已经有名称(表单),只需将
ng disabled=“form.$invalid”
添加到按钮(link?)。

由于表单已经有名称(表单),只需将
ng disabled=“form.$invalid”
添加到按钮(link?)。

使用
ng submit
指令

这只允许您在表单有效的情况下提交


使用
ng submit
指令

这只允许您在表单有效的情况下提交