首页 > 编程知识 正文

vue 自定义表单验证,vue 正则表达式验证

时间:2023-05-06 16:49:59 阅读:181362 作者:158

这是公司Vue Element UI的项目。 的验证规则部署图:

样式代码:

divclass=' info ' v-if=' opens list ' H2 class=' info-h '情况反馈表/h2el-form ref=' stateform ' : model=' stateform ' class=' state forms ' 3360 rules=' rules ' El-rowtype=' flex ' 请选择lectv-model=' stateform.way ' placeholder=' @ codel=' El-option label='遮盖物' value='1'/El-option El-option El-option label=El-option El-option label='无联系' value='4'/El-option/El-select/El-form-iorm El-col-col : span=' 12 ' El-form-item label='操作者态度' class=' stateform ' prop=' attitude ' El-selectv-morve El-optionEl-optionlabel='良' value='2'/El-optionlabel='良' value='2)/El-option El-option El-option 提交/El-button/El-form-item/El-form/div js代码:

data () return ) rules: ) way: ) required:true,消息: )收听方法(,trigger:(change ),attititition trigger : ' change ' } }请确保表单为“:rules=“rules”。 以下是自定义规则。 请把图填进去。

样式代码:

El-formlabel-width=' 100 px ' class=' pass style ' : model=' formname ' 3360 rules=' edit form pwd ' ref=' formname e=' width :50 % ' clear able/El-input-- span style=' width 336050 % ' class=' pass span ' { { us span } el-form-itemel-form-item label='原始密码: ' prop=' oldpwd ' El-input style=' width 336050 % ' clearablev-model pwd ' El-input style=' width 336050 % ' clearablev-model=' El-form-item El-form-item label='确认密码: ' prop==El-form-item El-form-item El-buttontype=' primary ' @ click=' sub pass ' ' formname ' ' '提交/El-button/El -提交

data ()//此处为自定义规则varnewpwdmin=(rule,value,callback ) ) if (! value ) {returncallback(newerror ) }“请输入密码”); }elseif(value!==this.formname.newpwd (返回呼叫(new error ) '输入两次密码不匹配!' ); } else { callback (} } return (edit form pwd : ) OldPwD: ) ) required:true,message: )原始密码', 请输入triggger: ) newpwd:[{ required: true,消息: '密码',trigger:'blur ',],newpwds :

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。