Check of date range selected by element-ui

the backend asked to make the selection of this date range a required entry in the form, but did not find the corresponding check in element-ui. I tried to fill in required and message, in rules, but when I did not select a time, the word "Please choose a time" did not appear on the page. Can anyone help me answer it? thank you

May.25,2021

you can customize a test

data(){
    var validDate = (rule,value,callback) => {
        if(!value[0] || !value[1]){
            callback(new Error(""))
        }else{
            callback()
        }
    }
    return {
        rules: {
            daterange: [{
                validator: validDate,
                trigger: 'blur'
            }]
        }
    }
}

you can also do more complex verification, such as whether daterange is an array type, and validation of date intervals


http://element-cn.eleme.io/-sharp/.
Form component provides the function of form validation by passing in the agreed validation rules through the rules attribute and setting the prop property of Form-Item to the field name to be verified. Take a closer look at the document

Menu