Angular 2开发人员极端dx-date-box验证必填字段 [英] Angular 2 dev extreme dx-date-box validation of required field

查看:42
本文介绍了Angular 2开发人员极端dx-date-box验证必填字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用dx-date-box进行日期输入,但无法使其验证我的表单上的必需值:

I'm trying to use dx-date-box for date inputs but I can't make it validate required values on my form:

<dx-date-box placeholder="Request Date" required="true"
          formControlName="request_date" type="date" validationMessageMode="always" invalidDateMessage="{{VALIDATION.DATE_INVALID}}">
        </dx-date-box>

无效的日期验证正在运行,并且显示该消息,但不会验证所需的值,也不显示所需的错误.我不确定如何实现这种行为.

Invalid date validation is working and it shows the message, but it wont to validate required value and doesn't show required error. I'm not sure how to achieve that behaviour.

推荐答案

我从DevExtreme文档中找到了这段代码

I found this code from DevExtreme Documentation

在元素中添加 dx-validator ="dobValidationRules" ,然后在angularJS中定义 dobValidationRules .

Add dx-validator="dobValidationRules" to element and in angularJS, define dobValidationRules.

$scope.dobValidationRules = {
        validationRules: [{
            type: "required",
            message: "Date of birth is required"
        }, {
            type: "range", 
            max: maxDate, 
            message: "You must be at least 21 years old"
        }]
    };

请在此处中找到实际的工作版本>

Please find the actual working version here

这篇关于Angular 2开发人员极端dx-date-box验证必填字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆