简体   繁体   English

如何保持禁用提交按钮,直到表单数据未填充响应式验证?

[英]How to keep submit button disable until form data did not filled with reactive validation?

How can you keep a form button disabled until form data is filled in reactive form? 如何在表单数据填充为反应形式之前保持禁用表单按钮的作用? I have created a reactive form here . 我在这里创建了一个反应形式。

And also how can you reset reactive forms and clear the data after a submit? 还有,如何在提交后重置反应形式并清除数据?

You could just use the FormGroup object you created "registerForm". 您可以只使用您创建的“ registerForm” FormGroup对象。 This object is really powerful. 这个对象真的很强大。 Check out the documentation on it. 查看有关文档。

https://angular.io/api/forms/FormGroup https://angular.io/api/forms/FormGroup

I do this all the time :) 我一直在做这个:)

  <button [disabled]="!registerForm.valid" class="btn btn-primary">Register</button>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 提交后如何在 Angular 反应形式中禁用按钮 - How to disable button in Angular reactive form after submit 如何禁用提交按钮,直到表单在角度 12 中有效? - How to disable submit button until form is valid in angular 12? 角度表单验证禁用提交按钮 - Angular form validation disable submit button 如何在 PrimeNg 日历未填充之前保持按钮禁用 - How to keep the button disabled until PrimeNg calendar is not filled 反应形式如何提交其他数据 - Reactive form how to submit additional data 如何使用 angular 中的相同提交按钮更新和提交反应式表单? - How to update and submit a reactive form using the same submit button in angular? Angular 反应式表单,输入提交空数据但按钮提交工作 - Angular reactive form, enter submitting empty data but button submit works 如何进行表单验证,我想在填写所有输入时启用提交按钮,否则应禁用它 - How to do form Validation, I want to enable submit button when all the input is filled otherwise its should be disabled 基于复选框和表单验证无效的提交按钮禁用 - Submit button disable based on checkbox and form validation not working 按钮单击时的反应式表单验证 - Reactive Form Validation on Button Click
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM