i want to validate user input for alphanumeric characters and for that im using
var regex = /^[a-zA-Z_0-9]$/;
var asdfsfd = $('#vcr_LinkName').val();
if (regex.test(asdfsfd)) {
alert("true");
} else {
alert("false");
}
but it always go into false condition what im doing wrong
Your expression would only match one single character.
Try this:
^[a-zA-Z_0-9]+$
Or
^\w+$
regards
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.