输入框input只能输入数字和小数点

输入框input只能输入数字和小数点

 

只允许输入数字(整数:小数点不能输入)
<input type="text" onkeyup="value=value.replace(/[^\d]/g,'')" > 
允许输入小数(两位小数)
<input type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" > 
允许输入小数(一位小数)
<input type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*$/g, '$1')" > 
开头不能为0,且不能输入小数
<input type="text" onkeyup="value=value.replace(/[^\d]/g,'').replace(/^0{1,}/g,'')" >

posted @   silentmuh  阅读(6204)  评论(0编辑  收藏  举报
Live2D
欢迎阅读『输入框input只能输入数字和小数点』
  1. 1 Walk Thru Fire Vicetone
  2. 2 爱你 王心凌
  3. 3 Inspire Capo Productions - Serenity
  4. 4 Welcome Home Radical Face
  5. 5 粉红色的回忆 李玲玉
Inspire - Capo Productions - Serenity
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

纯音乐,请欣赏

点击右上角即可分享
微信分享提示