+
95
-

js怎么限制input数字保留2位小数点?

js怎么限制input数字保留2位小数点?并且兼容ios 和andriod


网友回复

+
15
-

正则

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
    <input type="text" name="moneyinput"BfwOnkeyup="clearNoNum(this)" />元
    <script type="text/javascript">
        function clearNoNum(obj) {
            obj.value = obj.value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
            obj.value = obj.value.re...

点击查看剩余70%

我知道答案,我要回答