只能輸入英文
<input type="text" onkeyup="value=value.replace(/[^a-zA-Z]/g,'')">
身份證號(hào)只能輸入數(shù)字和英文x
<input type="text" onkeyup="value=value.replace(/[^\d\x\X]/g,'')">
只能輸入數(shù)字,小數(shù)點(diǎn):
<input type="text" onkeyup="value=value.replace(/[^\d\.]/g,'')">
不能為空
<input onblur="if(this.value.replace(/^ +| +$/g,'')=='')alert('不能為空!')">
只能輸入中文
<input type="text" onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')">
驗(yàn)證郵箱
<input type="submit" class="stdbtn" onclick="return checkEmail()"/>
function checkEmail(e){
console.log(e)
var $email=$("#email").val();
if(!$email.match(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/)){
alert("格式不正確舷嗡!請(qǐng)重新輸入");
$("#email").focus();
return false;
}
}