时间: 2024-03-07 【学无止境】 阅读量:共440人围观
简介 密码至少包含大写,小写字母,数字或特殊字符其中三种,长度8至16位(不包含空格)
<a-form-item label="新密码" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-input placeholder="请输入新密码" type="password" v-decorator="['newPwd', {rules: ['newPwd',{required: true, message: '请输入新密码'},{validator: validatorPwd}], trigger: 'blur'}]"></a-input> </a-form-item>
校验方法
validatorPwd (_rule, value, callback) { //必须包含大小写字母、数字、特殊字符长度再8-16位之间 let pwdRegex = new RegExp(/^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&*`~()-+=]+$)(?![0-9\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]{8,16}$/) if (value == '') { callback(new Error("请输入密码")) } else if (!pwdRegex.test(value)) { callback(new Error('密码至少包含大写,小写字母,数字或特殊字符其中三种,长度8至16位(不包含空格)')) } else { callback() } }