Write this function in onkeypress(onkeypress="return allowOnlyNumeric(event,numeric);") of the control:
var numbers = '1234567890';
var numeric = '1234567890.';
function allowOnlyNumeric(e, allow) {
var chCode = (e.which) ? e.which : e.keyCode;
if (typeof document.getElementById != 'undefined' && typeof document.all == 'undefined') {
if ((35 < e.charCode && e.charCode < 41)) return false;
if ((35 < chCode && chCode < 41) || chCode == 46) return true;
}
if (!(allow.indexOf(String.fromCharCode(parseInt(chCode))) != -1 || parseInt(chCode) == 8 || parseInt(chCode) == 13 || parseInt(chCode) <= 31))
return false;
return true;
}
No comments:
Post a Comment