登录页面开发全解析
1. 创建自定义 VTypes
许多系统对密码有特殊格式要求。例如,我们可能需要密码至少包含一个数字(0 - 9)、一个小写字母、一个大写字母、一个特殊字符(如 @、#、$、% 等),且长度在 6 到 20 个字符之间。
为了验证用户输入的密码是否符合此格式,我们可以创建一个正则表达式,并使用自定义 VType 来完成验证。以下是创建自定义 VType passRegex 的代码示例:
Ext.apply(Ext.form.field.VTypes, {
customPass: function(val, field) {
return /^((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20})/.test(val);
},
customPassText: 'Not a valid password. Length must be at least 6 characters and maximum of 20Password must contain one digit, one letter lowercase, one letter uppercase, onse special symbol @#$% and between 6 and 20 characters.',
});
在上述代码中, customPass 是自定义 VType 的名称,它是一个函数,用于验证输入的密码是否符合正则表达式。 <
超级会员免费看
订阅专栏 解锁全文
1185

被折叠的 条评论
为什么被折叠?



