如何禁用表单中的按钮?

雷扎努里

我希望在表单完成时禁用注册按钮。

<form [formGroup]="service.formModelInstrumexts" autocomplete="off" (submit)="onSubmit()"
  style="background-color: #0067b8 !important; margin-top: 25px; margin-left: 600px; margin-right: 600px;">
  <div style="padding: 15px">

<div>
  <h3 style="color: azure">
    اضافه کردن ساز
  </h3>
</div>
    <select   id="ddl" style="width:200px; margin-right: 1%; margin-bottom: 10px; border-radius: 0px;" dir="rtl"
      class="custom-select custom-select-sm">
      <option> لطفا نوع ساز را انتخاب نمایید</option>
      <option *ngFor="let item of type; let i = index" style="color: black;" (click)="test(item.id)" >{{item.name}}
      </option>
    </select>

    <div class="form-group">
      <label>نام</label>
      <input style="width: 40%; margin-left: 60%; border-radius: 0px;" class="form-control" formControlName="Name">
    </div>

    <div class="form-group">
      <label>توضیحات</label>
      <textarea [(ngModel)]="name"  style="direction: rtl; color: rgb(3, 0, 0); border-radius: 0px;" class="form-control" formControlName="Comment"
        aria-label="With textarea"></textarea>
    </div>


    <div  *ngIf="name != null" >
      <app-upload style=" width: 100px; "
        (onUploadFinished)="uploadFinished($event)"></app-upload>
      <img src="http://localhost:54277/{{this.response.dbPath}}" *ngIf="this.response.dbPath != null" width="200px"
        height="200px">
    </div>

    <div class="form-row">
      <div class="form-group col-md-8 offset-md-2">
        <button style="width: 100px; color: #0067b8; background-color: #fff; border-color: transparent; border-radius: 0px;margin-left: 8px;" type="submit" class="btn btn-lg btn-block"
          [disabled]="!service.formModelInstrumexts.valid" >ثبت
        </button>
      </div>
    </div>
  </div>
</form>
奥马尔·纳比尔

您的提交按钮将取决于表单有效性。

[disabled]= "!service.formModelInstrumexts.valid"

另一种方法是模板引用变量

<form #myForm [formGroup]="service.formModelInstrumexts"  (submit)="onSubmit()">

然后

[disabled]= "!myForm.valid"

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何禁用HTML表单中的“提交”按钮?

Xamarin表单-如何禁用MasterDetailPage菜单按钮

如何禁用表单外的提交按钮

如何启用或禁用表单上的按钮?

禁用/启用表单中的按钮提交

禁用Xamarin表单中的ScrollView而不禁用按钮

当同级ng-include中的表单为$ invalid时,如何禁用ng-include中的按钮?

在LibreOffice Base 5.0.2.2中如何创建按钮以禁用表单中的控件

如何禁用jQuery中的<a>按钮?

如何禁用Kotlin中的按钮?

如何使用全局变量在Angular模板驱动的表单中启用或禁用按钮?

如何在 Dynamics CRM 2016 中禁用基于表单的功能区按钮?

如何在附件表单视图odoo11中禁用清除按钮?

如何在Oracle表单中管理禁用/启用“最小化,调整大小和关闭”按钮?

表单按钮未禁用

表单按钮禁用外观

禁用按钮仍提交表单

禁用/启用Blazor中的按钮-取决于表单中的内容

如何通过按单选按钮禁用表单输入?

如何禁用表单按钮直到功能完全完成

当字段无效时,如何禁用 Antd 表单外的提交按钮?

表单为空时如何禁用提交按钮

如何通过 dlookup 功能启用和禁用表单上的按钮?

表单无效时如何禁用角度的外部按钮

单击Xamarin表单后如何临时禁用按钮?

如何在动态呈现的表单上禁用登录按钮

表单字段为空时如何禁用提交按钮?

如何根据React上的输入表单来禁用/启用按钮?

当表单无效时禁用angularJs中的外部按钮