如何在JQWidget控件上以模板驱动的角度形式进行数据验证

时间:2020-07-15 16:55:36

标签: angular validation jqwidget angular-template-form

我有一个模板驱动的表单,其中正在使用jqxDateTimeInput控件,但它不会触发Form上的脏/未更改标志。

代码段:

<form #myForm="ngForm" (ngSubmit)="performSubmit(myForm)" ngNativeValidate>
  <div class="form-group" *ngFor="let item of itemList">
    <div class="form-group row">
      <label [for]="item.id" class="col-sm-2 col-form-label">{{item.name}}</label>
      <div [ngSwitch]="item.dataType" class="col-sm-10">
      <div *ngSwitchCase="'date'">
         <jqxDateTimeInput [id]="item.id" [name]="item.id" class="form-control"   
            [placeHolder]="item.helpText?item.helpText:''"
            [showTimeButton]="item.validation?.showTime" [(ngModel)]="item.jqxDate" 
            [readonly]="item.isReadOnly" [disabled]="item.isReadOnly"
            [min]="item.minVal" [max]="item.maxVal"
            theme="bootstrap" width="100%"
            [template]="item.jqxDateTemplate?item.jqxDateTemplate:'default'"
            [formatString]="item.validation.dateFormat?item.validation.dateFormat:'d'"
            [showWeekNumbers]="item.validation.showWorkWeek">
          </jqxDateTimeInput>

功能可以正常设置/检索日期,使用最小和最大日期。但是数据验证是个问题。

  1. 当我在jqxDateTimeInput控件中设置初始日期值时,表单变脏且未触碰。
  2. 当我更改日期值时, still 表单仍然很脏且未修改

对于常规HTML5控件,表单验证可以正常工作。

如何使数据验证有效?

谢谢

RDV

0 个答案:

没有答案
相关问题