在HTML中限制input 输入框只能输入纯数字

oninput="value=value.replace(/[^\d]/g,'')"

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>input</title>
</head>
<body>
    只能输入纯数字的输入框:<input type="text" name="" oninput="value=value.replace(/[^\d]/g,'')">
</body>
</html>

 

posted @ 2019-07-11 09:56  秋寻草  阅读(21141)  评论(0编辑  收藏  举报