开发者

How do I validat a password and make sure that the username is not used?

开发者 https://www.devze.com 2023-01-30 14:08 出处:网络
Can I get an example of how I would change the following code to make sure that the regEx does not allow a end user to not enter their username when they are creating a password?

Can I get an example of how I would change the following code to make sure that the regEx does not allow a end user to not enter their username when they are creating a password?

Here is the regEx for the username:

createFieldObjects: function(){
unField = new form开发者_Python百科s.InputField("tUserName", /^(?=.*[a-zA-Z\d])(\w|[\.\@\-\?\,\&\''\/\_\""]){6,}$/);
},

Here is the regEx for the password:

createFieldObjects: function(){
if ( dojo.byId("tPassword") ) {
    pwField = new forms.InputField("tPassword", /^(?:(?!([a-zA-Z0-9-().&@?""#,+''\s\/])\1\1)[a-zA-Z0-9-().&@?""#,+''\s\/]){7,}$/);
} else if ( dojo.byId("newPassword") ) { 
    pwField = new forms.InputField("tPassword", /^(?:(?!([a-zA-Z0-9-().&@?""#,+''\s\/])\1\1)[a-zA-Z0-9-().&@?""#,+''\s\/]){7,}$/);
}   
},


While not exactly an answer for your question, I would make the username != password check a separate statement, to checked after form submission. This would also give your form the chance to provide a meaningful error message as to why the password is unacceptable.

0

精彩评论

暂无评论...
验证码 换一张
取 消