|
只能输入数字
<input onKeyUp="value=value.replace(/D+/g,\'\')">
只能输入中文
<input onKeyUp="value=value.replace(/[ -}]/g,\'\')">
字符长度
form onsubmit=check(this.test4,4)>
<input name=test4 onKeyUp="value=value.replace(/[ -}]/g,\'\')">><input type=submit>
</form>
<script>
function check(ob,num){
if(ob.value.length>=num)
return;
alert("4 or more characters expected");
event.returnValue=false;
}
</script>
本文由胡金金个人网站整理发布,转载请注明地址:http://www.hujinjin.com/info/214.html