I have the following JavaScript function that uses regexp to not allow typing of letters or special chars into a text box, the problem is that the users will also hve to use ctrl+C, ctrl+v the backspace key the F keys ect. these keys work fine in IE but in Firefox they do not work.
Can anyone help me out,
Thanks,
JS code:
function check_float(e, field) {
//alert(e.keyCode);
var key;
var code;
if (window.event) {
key = String.fromCharCode(e.keyCode);
code = e.keyCode;
}
else if (e.which) {
key = String.fromCharCode(e.which);
code = e.which;
}
if (key.match(/[~!@\+=\''#\""$%\{\}\[\]\\^&*()a-zA-Z]/i)) {
alert("Only digits, dashes and decimal points are allowed!");
return false;
} else {
//alert('key match');
}
}
Ordinary Programmer
Can anyone help me out,
Thanks,
JS code:
function check_float(e, field) {
//alert(e.keyCode);
var key;
var code;
if (window.event) {
key = String.fromCharCode(e.keyCode);
code = e.keyCode;
}
else if (e.which) {
key = String.fromCharCode(e.which);
code = e.which;
}
if (key.match(/[~!@\+=\''#\""$%\{\}\[\]\\^&*()a-zA-Z]/i)) {
alert("Only digits, dashes and decimal points are allowed!");
return false;
} else {
//alert('key match');
}
}
Ordinary Programmer