Using element-ui, the form validation is pretty decent, so I was expecting it to be pretty straight-forward to "wire up" a variable that represents whether the form is valid to the "submit" button.
I can certainly write a validation function and attach it to appropriate events on every field, but that seems duplicative.
For example, each rule already has a trigger that tells it when to evaluate the rule (e.g. blur, change). If I have to attach an event to each el-input that mirrors the same triggers, that feels fragile to me.
For example, these rules trigger on blur or change.
rules: {
username: [
{
required: true,
message: "please enter user name",
trigger: "blur"
},
{
min: 3,
max: 32,
message: "length must be 3 to 32 characters",
trigger: "blur"
}
],
password: [
{
required: true,
message: "please enter password",
trigger: "change"
}
]
}
Am I missing something? Is there a way to do this, uh, elegantly?