newbie newbie - 1 year ago 39
Javascript Question

JavaScript regex for alphanumeric string with length of 3-5 chars

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;

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download