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(*)
What is a primary key? A primary key is a column ...
Table of contents 1. Experimental Environment 2. ...
Monday to Sunday time format conversion (Y --- ye...
This article uses vue, and adds mouse click event...
On Saturday, the redis server on the production s...
Under Linux, if you download and install an appli...
1 Download The address is: https://dev.mysql.com/...
Configuration Instructions Linux system: CentOS-7...
I believe everyone has had this feeling: watching ...
Table of contents Preliminary work Backend constr...
introduction Most people who have used databases ...
Table of contents 2 solutions for file upload Bas...
The virtual machine is in use or cannot be connec...
1. Check the MySQL database encoding mysql -u use...
<br />The color of a web page is one of the ...