简体   繁体   English

所有字段填写完毕后发生的事件

[英]Event after all fields filled

I have 4 inputs and 1 button which is disabled 我有4个输入和1个禁用的按钮

<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="button" disabled="true">

How I can remove attribute disabled from button after all fields will be filled. 填写所有字段后,如何从按钮中删除禁用的属性。 Something another events oninput and onchange. 输入和变化发生了另外一些事件。

Use the ionic validation 使用离子验证

https://ionicframework.com/docs/developer-resources/forms/ https://ionicframework.com/docs/developer-resources/forms/

Look for this line and its example: 查找此行及其示例:

<button ion-button type="submit" [disabled]="!todo.valid">Submit</button>

You can do this by using FormGroups 您可以使用FormGroups完成此操作

app.component.html app.component.html

     <form [formGroup]="mygroup" >

           <input type="text" formControlName="input1">
           <input type="text" formControlName="input2">
           <input type="text" formControlName="input3">
           <input type="text" formControlName="input4">

           <input type="button" disabled="true" type="submit" [disabled]="!mygroup.valid">
        </form>

app.component.ts app.component.ts

import { Component } from '@angular/core';
import {Validators, FormBuilder, FormGroup } from '@angular/forms';


export class FormsPage {
  private mygroup : FormGroup;

  constructor( private formBuilder: FormBuilder ) {
    this. mygroup = this.formBuilder.group({
      input1: ['', Validators.required],
      input2: ['', Validators.required],
      input3: ['', Validators.required],
      input4: ['', Validators.required],
    });
  }

}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM