正則表示式驗證郵箱、金額
阿新 • • 發佈:2018-12-10
1.驗證郵箱正則表示式
var regEmail = /^[a-zA-Z0-9_-][email protected][a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
2.驗證金額正則表示式
var regMoney = /^([1-9]\d{0,9}|0)([.]?|(\.\d{1,2})?)$/;
3.文字框驗證必須是數字,不能帶有小數點-->手機號驗證
<input type="text" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
4.文字框驗證只能輸入英文。不能輸入中文或數字以及相應的特殊字元
<input type="text" onkeyup="this.value=this.value.replace(/[^a-zA-Z]/g,'')">
5.文字框只能輸入數字程式碼(小數點也不能輸入)
<input onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
6.只能輸入字母和中文
<input onkeyup="value=value.replace(/[\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[\d]/g,''))" maxlength=10 name="Numbers">
7.只能輸入字母和數字
<input onkeyup="value=value.replace(/[^\w\.\/]/ig,'')">
8.文字框只能輸入數字程式碼(小數點也不能輸入)
<input onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">