function checkSpecial(obj,objEvent)
{
var specialChar = "^[A-Za-z0-9_]+$" //regular expression defining a 5 digit number
var objVal = obj.value;
var objVallen = obj.value.length;
if (objVal != "")
{
if (objVal.search(specialChar) == -1) //if match failed
{
if (objEvent == "keyup") {
if (objVallen > 1) {
obj.value = objVal.substring(0, parseInt(objVallen) - 1);
}
else {
obj.value = "";
}
}
else {
obj.value = "";
}
alert("Invalid character");
obj.focus();
}
}
}