html input 設定只能輸入數字
{# 輸入0時,也會生效 #}
<input type="text" class="form-control" style="width:75px;display: inline;" onkeyup="value=https://blog.csdn.net/weixin_43633797/article/details/value.replace(/[^/d]/g,'')">
{# min作用只在submit時生效 #}
<input type="text" class="form-control" style="width:75px;display: inline;" onkeyup="value=https://blog.csdn.net/weixin_43633797/article/details/value.replace(/[^/d]/g,'')" min='1'>
{# 完美解決 #}
<input type="number" style = "width:80px" placeholder="1~54" oninput="if(value > 54 || value < 1 ){showAlert('', '非法輸入', 3000);valuehttps://blog.csdn.net/weixin_43633797/article/details/= ''}"/>
<script>
function showAlert(parms, msg, time) {
if (parms){
toastr.success(msg, 'Tips:');
setTimeout(function () {
toastr.clear();
}, time)
} else {
toastr.error(msg, 'Tips:');
setTimeout(function () {
toastr.clear();
}, time)
}
}
</script>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/2759.html
標籤:其他
下一篇:前端傳遞多個物件的資料到后臺
