Home >Web Front-end >JS Tutorial >jquery tutorial restricts the text box to only input numbers and decimal points example sharing_jquery

jquery tutorial restricts the text box to only input numbers and decimal points example sharing_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 17:03:571144browse

Copy code The code is as follows:

$(function(){                                                  Limit the text box to only numbers*/
$(".NumText").keyup(function(){
^0/g,''));
                                                                                                            . .replace(/D|^0/g,''));                                                                                                             *JQuery limits the text box to only numbers and decimal points*/
$(".NumDecText").keyup(function(){
(/[^0-9.]/g,''));                                                                                                                                 (this).val().replace(/[^0-9.]/g,''));  
       }).css("ime-mode", "disabled"); //CSS setting input Method not available                                                           
Then add the class name to the text box that needs to be verified, similar to the following:




Copy the code


The code is as follows:


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