Click to See Complete Forum and Search --> : Text Input Validation
I would like to validate a user text box input, to make sure it contains the alphabetic and numeric characters only. Is there any function in Javascript's library performing this checking?
Thank you for your help,
Thuy
skriptor
07-23-2003, 02:34 AM
Hi,
try this:
a = 'huhu"huhu'
alert ( a.search( /[^A-Za-z0-9]/ ));
Good luck, skriptor
This is my validation function. It works just fine, but I thought it would be nicer if there is any built in function.
function InvalidPW(){
var Password = document.NewMember.Password1.value;
for(var i = 0; i < Password.length; i++){
if((Password[i] < "0") || (Password[i] > "9" && Password[i] < "A") ||
(Password[i] > "Z" && Password[i] < "a") ||(Password[i] > "z"))
return false;
}
return true;
}
Also, thank you for your response Skriptor. I'll try your.
Thuy
Thank you Skriptor. It works, and very clean.
Thuy