Hey all,

Right now I have a portion of a script that alerts when you aren't using numbers or letters into the text input. I want it so when it not only alerts, but removes the bad character. If I type in any of these.. -.)(*%^$#&^ it will say "You can only use numbers are letters". But I want to then automatically replace those illegal characters with nothing so the rest of the text stays in tact.

Heres my code.

Code JavaScript:
var subdomain = document.getElementById('subdomain');  
	var alphaExp = /^[0-9a-zA-Z]+$/;
 
	if(!subdomain.value.match(alphaExp)){
		alert('You can only use numbers and letters in your subdomain!');
		return false;
	} else {
		var domain = document.getElementById('subdomain').value+'.'+document.getElementById('domain').value;
		var url="checkdb.php?account="+domain;
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}