problem
i was implementing user cannot enter special character in textbox.
script is working on ie, safari, chrome but mozilla treating as special character.
what i need
- i need backspace so that user can edit textbox values.
html code
<input type="text" id="school" name="school"/>
js code
$("#school").bind('keypress', function (event) {
var regex = new RegExp("^[a-zA-Z0-9]+$");
var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
console.log(key);console.log(flag);
if (!regex.test(key) && flag=="false") {
console.log("if");
//jQuery("#errmsg").html(localStorage.getItem("datas")).show();
event.preventDefault();
return false;
}
else
{
console.log("else");
}
//alert(data);
});
js fiddle link : http://jsfiddle.net/HGJb3/295/
any help is most appericiated.
i came up with solution : http://jsfiddle.net/HGJb3/297/ now it works