Home >Web Front-end >JS Tutorial >Javascript regular control text box can only input integers or floating point numbers_javascript skills
JS part of the code is as follows:
function CheckInputIntFloat(oInput) { if('' != oInput.value.replace(/\d{1,}\.{0,1}\d{0,}/,'')) { oInput.value = oInput.value.match(/\d{1,}\.{0,1}\d{0,}/) == null ? '' :oInput.value.match(/\d{1,}\.{0,1}\d{0,}/); } }
HTML part code (example):
<input type="text" id="input1" name="input1" onkeyup="javascript:CheckInputIntFloat(this);" />