[Vuejs]-Using Vue.js and element UI, How to make required field optional depend on checkbox value?

0👍

You can use a computed property called rules to have dynamic rules reactive like you want :

computed: {
    rules() {
        const isRequired = this.MainForm.mycheckbox === false;
        return {
          value1: [
            { required: isRequired, message: 'Please input Activity name'},
          ],
          value2: [
            { required: isRequired, message: 'Please input Activity name'},
          ],
        }
    }
}

Leave a comment