I've to put validation for password. Password must be of 8 characters (min = 8 char and max = 10 char). And should contain at least 1 uppercase character, 1 lowercase character, 1 special character and 1 number. Till now what I've done is below...
['validate-password', 'Password must contain at least 1 uppercase character, 1 lowercase character, 1 special character and 1 number (Min. length = 8 & Max. length = 10)', function(v) {
var pass=v.strip();
if(pass.length <11 && pass.length>7)
return Validation.get('IsEmpty').test(v) || /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])/.test(v) || /^\s|\s$/.test(pass)
}],
This code works fine, but when I add white space at the starting of password, e.g. password = 2 whitespaces + Aaaa#7 then it is showing alert message but when I add 2 more characters at the end like password = 2 whitespaces + Aaaa#7 + 12 then it is accepting. What I want here is removal of whitespace at the beginning and at the end of string... How can I do that???