function check(e) { var re = /^\d+(?=.{0,1}\d+$|$)/ if (e.value != "") { if (!re.test(e.value)) { alert("請輸入正確的數字"); e.value = ""; e.focus ...
第一步 添加js方法 function check e var re d . , d if e.value if re.test e.value alert 請輸入正確的數字 e.value e.focus 第二步 調用 加粗的都要有 lt input type text id achievementScore class tab bor name scoreCheck.achievementS ...
2016-11-29 16:35 0 25552 推薦指數:
function check(e) { var re = /^\d+(?=.{0,1}\d+$|$)/ if (e.value != "") { if (!re.test(e.value)) { alert("請輸入正確的數字"); e.value = ""; e.focus ...
<input type="text" placeholder="保留到小數點后兩位" maxlength="200" onkeyup="num(this)" onpaste="num(this)" /> //輸入和黏貼操作時觸發 //小數點后兩位 function num ...
<input type="text" class="txt NumText" Width="100px" /> $(function(){ /*JQuery 限制文本框只能輸入數字 ...
1.文本框只能輸入數字代碼(小數點也不能輸入)<input onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">2.只能輸入數字 ...
js代碼如下: <script language="JavaScript" type="text/javascript"> function clearNoNum(obj){ obj.value = obj.value.replace(/[^\d.]/g ...