Code: <input type="text" class="txt" name="qty" value="" onkeyup="this.value=this.value.replace(/[^0-9\.]/g,'')" /> PS: js implements a text box that can only input numbers and decimal points <html><head><meta http-equiv="content-Type" content="text/html;charset=gb2312"><title>js can only input numbers and decimal points</title> <script language="JavaScript" type="text/javascript"> function clearNoNum(obj){ obj.value = obj.value.replace(/[^\d.]/g,""); //Clear characters other than "number" and "." obj.value = obj.value.replace(/^\./g,""); //Verify that the first character is a number and not a . obj.value = obj.value.replace(/\.{2,}/g,"."); //Only keep the first one. Clear the rest. obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); } </script> </head><body>Text box that can only input numbers and decimal points: <input name="input1" onkeyup="clearNoNum(this)"></body></html> The above is the full content of this article. I hope that the content of this article can bring some help to your study or work. At the same time, I also hope that you can support 123WORDPRESS.COM! |
<<: Detailed explanation of how two Node.js processes communicate
>>: Let's talk about the performance of MySQL's COUNT(*)
Table of contents 1 Introduction 2 Prerequisites ...
1. Unzip the mysql compressed package to the /usr...
What is a web page? The page displayed after the ...
Table of contents Preface text 1. Panel 2. Huaron...
I have previously shared the usage of asynchronou...
According to Chinese custom, we are still celebra...
Author: Ding Yi Source: https://chengxuzhixin.com...
Kubernetes supports three types of authentication...
Since the introduction of the contentEditable attr...
1. Experimental Environment serial number project...
1. Create a new rtmp directory in the nginx sourc...
Table of contents Overview Code Implementation Si...
Table of contents 1: Introduction to galera-clust...
Implementation effect: 1. count(1) and count(*) W...
Table of contents 1. forEach() 2. arr.filter() 3....