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(*)
We, humble coders, still have to sing, "You ...
The innodb_autoinc_lock_mode parameter controls t...
I believe everyone has used JD. There is a very c...
This article example shares the specific code for...
Table of contents mysql filtered replication Impl...
Today, I encountered a little problem when I was ...
This article shares the specific code of jQuery t...
A colleague asked me what N and M mean in the MyS...
1. Add in package.json "main": "el...
Error message: Store update, insert, or delete st...
Table of contents Background of this series Overv...
1. Command Introduction The userdel (user delete)...
01. Command Overview dirname - strip non-director...
1. Download MySQL Workbench Workbench is a graphi...
This article example shares the specific code of ...