gpt4 book ai didi

javascript - 当我所有的 Ng-from 都有效时启用一个按钮

转载 作者:行者123 更新时间:2023-11-30 16:57:44 25 4
gpt4 key购买 nike

 <div ng-show="!login.SecQuestions && !login.ResetUser">
<h3>Answer security questions</h3>
<ul>
<li>
<label>Please answer the following question(s)</label>
</li>
</ul>
<ul>
<li>
*= required field
</li>
</ul>

<ul ng-repeat="Question in login.SecurityQuestions">
<li>
{{Question.Question}}
</li>
<li>
<ng-form name="SecQuestionForm" novalidate>
<textarea name="SecurityAnswer" ng-model="Question.Answer" type="text" required></textarea>
<span style="color:red" ng-if="SecQuestionForm.SecurityAnswer.$dirty" ng-show="SecQuestionForm.SecurityAnswer.$invalid">required.</span>
</ng-form>
</li>
</ul>

<ul>
<li>
<button class="primaryButton" ng-disabled="ResetNamePass.SecQuestionForm.$invalid" ng-click="Continue_2()">Continue</button>
</li>
</ul>
</div>

ng-Form 的动态验证启用按钮不会验证所有三个必填字段,它的启用取决于最后一个文本区域的要求。

错误截图

https://drive.google.com/folderview?id=0Bz2v151kdXv8fjNsc0VGLVpOOFNoRklCcTdZNjFkOWprOEYteENJTUN1YUZUbHRVc3hNaFE&usp=sharing

最佳答案

将你的 ng-form 放在一个表单中,然后在按钮上添加外部表单有效性的条件。

<form novalidate name='form1'>
<ul ng-repeat="Question in login.SecurityQuestions">
<li>
{{Question.Question}}
</li>
<li>
<ng-form name="SecQuestionForm" novalidate>
<textarea name="SecurityAnswer" ng-model="Question.Answer" type="text" required></textarea>
<span style="color:red" ng-if="SecQuestionForm.SecurityAnswer.$dirty" ng-show="SecQuestionForm.SecurityAnswer.$invalid">required.</span>
</ng-form>
</li>
</ul>

<ul>
<li>
<button class="primaryButton" ng-disabled="!form1.$valid" ng-click="Continue_2()">Continue</button>
</li>
</ul>
</form>

仅当所有嵌套的 ng-forms 都有效时,外部形式才有效

关于javascript - 当我所有的 Ng-from 都有效时启用一个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29409481/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com