Regex Object crashes IE

P

puneet.kandhari

The following code

Code:
function checkAlphanumeric(field,msg,errorspan){
var alphanmuer= /^[A-Za-z][-A-Za-z0-9_ ]{0,49}$/;
var strValue = document.getElementById(field).value;
if(strValue.length>1){
if (strValue.search(alphanmuer)!=-1) {
document.getElementById(errorspan).innerHTML = '';
return;
}
else{

document.getElementById(errorspan).innerHTML = msg;
document.getElementById(field).focus();
document.getElementById(field).select();
return;
}
}
else{
document.getElementById(errorspan).innerHTML = msg;
document.getElementById(field).focus();
document.getElementById(field).select();
return;
}
}

used with
<input type="text" name="username" id="username" onblur="javascript:
return checkAlphanumeric('username','Error: Please enter Alpha Numeric
only only.','username_error');"/>
always crashes IE and i dont see why.
help :)
 
E

Evertjan.

wrote on 11 nov 2005 in comp.lang.javascript:
var alphanmuer= /^[A-Za-z][-A-Za-z0-9_ ]{0,49}$/;
var strValue = document.getElementById(field).value;
if (strValue.search(alphanmuer)!=-1) {

if (!/^[a-z][- \w]{2,49}$/i.test(strValue)) {
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top