Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
57
rated 0 times [  59] [ 2]  / answers: 1 / hits: 123349  / 14 Years ago, thu, january 20, 2011, 12:00:00

I need regex for validating alphanumeric String with length of 3-5 chars. I tried following regex found from the web, but it didn't even catch alphanumerics correctly.



var myRegxp = /^([a-zA-Z0-9_-]+)$/;
if(myRegxp.test(value) == false)
{
return false;
}

More From » regex

 Answers
146

add {3,5} to your expression which means length between 3 to 5



/^([a-zA-Z0-9_-]){3,5}$/

[#94131] Tuesday, January 18, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jelani

Total Points: 473
Total Questions: 99
Total Answers: 99

Location: Cape Verde
Member since Fri, Nov 27, 2020
4 Years ago
;