Javascript regular control text boxes can only enter integers or floating point Numbers
- 2020-03-30 03:49:53
- OfStack
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 (sample) :
<input type="text" id="input1" name="input1" onkeyup="javascript:CheckInputIntFloat(this);" />