jQuery Regular Expression
So I wrote a custom method that restricts the username to specific alphanumeric characters and special characters. Everything works as intended except I want to make sure the username starts with a letter. Here is my code
- jQuery.validator.addMethod(
"RestrictSpecialCharacters",
function(value,element){
var hNum= /[^a-zA-Z0-9._]/;
var inp=jQuery.trim(element.value).toLowerCase();
if(hNum.test(inp)) {
return false;
}
else return true;
},
"Characters allowed: [A-Z] [0-9] [.] [_]"
);
How can a make it such that a letter will have to be the first character in the username?