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(*)
Monitoring method in Vue watch Notice Name: You s...
Recently, WeChat Mini Program has proposed adjust...
Virtualization and containerization are two inevi...
CocosCreator realizes skill CD effect There are s...
Table of contents 1. After downloading, unzip it ...
This article uses examples to describe MySQL tran...
1. MacVlan There are many solutions to achieve cr...
This article shares the specific code of JavaScri...
error message: ERROR 2002 (HY000): Can't conn...
Why does CSS have a cascading mechanism? Because ...
Table of contents 1. View the storage engine of t...
The system environment is server2012 1. Download ...
Table of contents Preface Standard sfc writing me...
Margin of parallel boxes (overlap of double margi...
Today I received a disk alarm exception. The 50G ...