Call Javascript function on “onkeyup” event of TextBox
function valid(field) { var txt = document.getElementById(‘TextBox1′).value; var iChars = “!@$%^&*()+=-[]\\\’;,./{}|\”:?~_”; for (var i = 0; i < txt.length; i++) { if (iChars.indexOf(txt.charAt(i)) != -1) { alert(“Your string has special characters. \nThese are not allowed.”); document.getElementById(‘TextBox1′).value = txt.substring(0, txt.length – 1); return false; } } }
function isSpclChar(){ var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":?"; for (var i = 0; i < document.qfrm.q.value.length; i++) { if (iChars.indexOf(document.qfrm.q.value.charAt(i)) != -1) { alert ("The box has special characters. \nThese are not allowed.\n"); return false; } } }