angular - 如果用户没有在当前页面的所有必填字段中输入数据,我不想允许进入下一步
问题描述
在从一个步骤移动到另一个步骤时,我们必须验证当前步骤字段。但它验证所有步骤字段。我们如何验证当前步骤字段而不是所有字段?
我正在使用带有反应表单的 Angular 4,我正在使用 angular-archwizard 制作多步表单,目前它允许我在不输入必填字段的所有值的情况下进入下一步,我不想允许,我想如果我在所有必填字段中输入了值,请转到下一步,
我怎样才能做到这一点 ???
以下是我的表格
<aw-wizard>
<aw-wizard-step stepTitle="Title of step 1">
<input type="text" formControlName="BillingAddressLine1" class="form-control"
[(ngModel)]="billingAddressLine1">
<button type="button" awNextStep>Next Step</button>
<button type="button" [awGoToStep]="{stepIndex: 2}">Go directly to third Step</button>
</aw-wizard-step>
<aw-wizard-step stepTitle="Title of step 2" awOptionalStep>
Content of Step 2
<button type="button" awPreviousStep>Go to previous step</button>
<button type="button" awNextStep>Go to next step</button>
</aw-wizard-step>
<aw-wizard-step stepTitle="Title of step 3">
Content of Step 3
<button type="button" awPreviousStep>Previous Step</button>
<button type="button" (click)="finishFunction()">Finish</button>
</aw-wizard-step>
</aw-wizard>
我希望该用户不应该进入下一步,直到它不输入 BillingAddressLine1 的值,因为此字段是必需的
解决方案
那么你需要将它与表单有效性联系起来:
<button
type="button"
awNextStep
[disabled]="yourFormName.status === 'INVALID'">Go to next step</button>
推荐阅读
- bash - 将输出作为文件名执行
- python - Wand 无法正确设置图像分辨率
- java - 我可以在 Spring 中注入一个 bean 的所有 impl 的 Map
- css - 从 Classpath 导入 Less-Files (Bootstrap Webjars)
- java - 如何在 Java 的缩放面板中操作形状?
- node.js - Mongoose Typescript 在 ref 字段上查找方法
- python - 编译的python脚本在其他机器上不起作用
- mysql - Mysql 仅从子字符串结果中选择数字
- excel - 将一列中的所有行在每行加 1 后乘以所有乘积后减去 1 的公式
- javascript - 如何使用 SnipCart 创建分层的自定义属性选择框?