This code works fine in IE but not FF. Looks like regular expression match function is not working correctly in FF. Please see the code below. Function restrictData always retuns true.
protected void Page_Load(object sender, EventArgs e)
{
textBox.Attributes.Add("onkeyup", "chkTextBox(this)");
}
javascript Code**
function chkTextBox(txb)
{
var bx = document.getElementById(txb.id);
if (restrictData(bx))
{
alert('You have used a special character. Please retype your answer without using special characters');
bx.value = "";
}
}
function restrictData(cnid)
{
var inputValid = true;
restrictSplChrRegex = "^(a-z|A-Z|0-9)*[^\]$%^&*~!?><.:\;\`/|\['\\\\\\x22]*$";
if (cnid.value.match(restrictSplChrRegex))
inputValid =true;
else
inputValid =false;
return inputValid;
}