need some help with regex and Jquery.
function cbprValidateUser(username){
var reg = /^[a-zA-Z'.,-]$/;
return (reg.test(username));
}
I want to use letters & numbers, no punctuation or spaces
Im rather lost
need some help with regex and Jquery.
function cbprValidateUser(username){
var reg = /^[a-zA-Z'.,-]$/;
return (reg.test(username));
}
I want to use letters & numbers, no punctuation or spaces
Im rather lost
Your regular expression is wrong. If you want only numbers and letter, use this: ^[a-zA-Z0-9]*
In your case:
function cbprValidateUser(username){
var username = username || '';
var reg = /^[a-zA-Z0-9]+$/
if (reg.test(username)){
return true; }
else{
return false;
}
}
Btw. this code is pure JavaScript ( no jQuery). Cheers