,""); //清除“數字”和“.”以外的字符 obj.value = obj.value.replace ...
工作中input text 總會遇到要控制輸入數字,或者是輸入中文,輸入電話,輸入身份證號,郵箱等。今天我遇到的是要輸入數字並且只能小數點后面兩位的數字,還不能為負數。廢話不多說上代碼: lt input id testinput onkeyup clearNoNum this gt script代碼部分: ...
2018-10-15 09:59 0 7360 推薦指數:
,""); //清除“數字”和“.”以外的字符 obj.value = obj.value.replace ...
<input type="text" placeholder="保留到小數點后兩位" maxlength="200" onkeyup="num(this)" onpaste="num(this)" /> //輸入和黏貼操作時觸發 //小數點后兩位 function num ...
//input輸入框只能輸入數字和 小數點后兩位 function num(obj,val){ obj.value = obj.value.replace(/[^\d.]/g,""); //清除"數字"和"."以外的字符 obj.value = obj.value.replace ...
1.給文本框添加一個onkeyup=’clearNoNum(this)’點擊事件 2.建立clearNoNum方法 1 2 3 4 5 6 7 8 3將金額小寫轉換成 ...
<!DOCTYPE html> <html lang="en"> <head> <meta ...
轉載自:http://blog.csdn.net/u012402177/article/details/52587649 ...