Html: <input type="text" onkeypress="return isNumberKey(evt)" />
JavaScript:
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57))
return false;
return true;
}
My Question Why there is return
used in onKeypress
event.
Code Explaination Basically after appling this function, input feild only accepts number. i am surprised, how input feild value is forced to received only number ? AsisNumberKey()
function only return ture / false not the value?