Using the below code, the text field can be changed to allow only the numbers, use can't enter text only numbers will be allowed.
------------------------------------------------------------------
jQuery( document ).ready(function() {
jQuery("#field-id-or-class").attr('onkeypress','return isNumberKey(event);');
});
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode;
console.log(charCode);
if (charCode != 46 && charCode != 45 && charCode > 31
&& (charCode < 48 || charCode > 57))
return false;
return true;
}
No comments:
Post a Comment