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.
精彩评论