vue.js帐号,密码,邮箱和移动手机号码正则验证

帐号,密码,邮箱和移动手机号码正则:

 

 

acc_regex: /^[a-zA-Z0-9_-]{4,16}$/,
                pwd_regex: /^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*? ]).*$/,
                email_regex: /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,
                mobile_regex: /^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[0,5-9])|(18[0,5-9]))\d{8}$/,
Source Code


应用,如帐号正则验证:

 

account_change: function (e) {
                const self = e.target.value
                if (self != '') {
                    this.isAccRegexValid(self);
                }
                else {
                    //验证失败
                }
            },
            isAccRegexValid: function (inputValue) {
                if (this.acc_regex.test(inputValue)) {
                    //正则验证成功
                }
                else {
                   //正则验证失败
                }
            },
Source Code

 

posted @ 2021-06-27 13:18  Insus.NET  阅读(438)  评论(0编辑  收藏  举报