all three paragraphs have the same small piece of code. How should I optimize the repeated code? and I would like to ask form validation do you all write your own verification rules or use plug-ins? Is it bad for me to write like this
setTimeout(() => {
ins.close()
}, 800)
return false
if (this.username == "" || this.pw == "" || this.pw2 == "") {
let ins = this.$toast("")
setTimeout(() => {
ins.close()
}, 800)
return false
} else if (regPw.test(this.pw) || regPw.test(this.pw2)) {
let ins = this.$toast("")
setTimeout(() => {
ins.close()
}, 800)
return false
} else if (this.pw !== this.pw2) {
let ins = this.$toast("")
setTimeout(() => {
ins.close()
}, 800)
return false
}
}