Home >Web Front-end >JS Tutorial >Javascript regular control text box can only input integers or floating point numbers_javascript skills

Javascript regular control text box can only input integers or floating point numbers_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:37:521361browse

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);" />
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn