Angular 2 dev extreme dx-date-box validation of required field

拥有回忆 提交于 2019-12-12 04:31:14

问题


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.


回答1:


I found this code from DevExtreme Documentation

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



来源:https://stackoverflow.com/questions/43503999/angular-2-dev-extreme-dx-date-box-validation-of-required-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!