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
Release: 2016-05-16 16:37:52
Original
1364 people have browsed it

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,}/); 
} 
}
Copy after login

HTML part code (example):

<input type="text" id="input1" name="input1" onkeyup="javascript:CheckInputIntFloat(this);" />
Copy after login
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template