0

我有一个owl-date-time组件

<input  class="form-control" [owlDateTime]="scheduleDate"
      [(ngModel)]="startTime">
       <div class="input-group-addon" [owlDateTimeTrigger]="scheduleDate">
            <i class="fa fa-calendar"></i>
      </div>
<owl-date-time  #scheduleDate showSecondsTimer="true"></owl-date-time>

在我的模块中:

export const MY_NATIVE_FORMATS = {
  fullPickerInput: { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' },
  datePickerInput: { year: 'numeric', month: 'numeric', day: 'numeric' },
  timePickerInput: { hour: 'numeric', minute: 'numeric' },
  monthYearLabel: { year: 'numeric', month: 'short' },
  dateA11yLabel: { year: 'numeric', month: 'long', day: 'numeric' },
  monthYearA11yLabel: { year: 'numeric', month: 'long' },
};

...

providers: [{ provide: OWL_DATE_TIME_FORMATS, useValue: MY_NATIVE_FORMATS }]

问题是用户可以在时间控件中输入字母(见图)

在此处输入图像描述

我可以阻止它吗?我想添加pattern="[0-9]{2}"到内部输入字段

可以这样做吗?

谢谢

4

0 回答 0