美文网首页js
js只能输入数字和小数点的正则

js只能输入数字和小数点的正则

作者: world_7735 | 来源:发表于2018-08-30 20:19 被阅读520次
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="" novalidate>
<input type="text" autocomplete="off" id="price" autofocus="autofocus" onkeyup="value=value.replace(/[^\d^\.]+/g,'')">
</form>
</body>
</html>

相关文章

网友评论

    本文标题:js只能输入数字和小数点的正则

    本文链接:https://www.haomeiwen.com/subject/nyndwftx.html