<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
function CheckString(){
var strTmp=document.all.txt.value;
var intTmp=parseInt(strTmp)
if (isNaN(intTmp))
alert("All String");
else if (intTmp==strTmp)
alert("All Numeric");
}
</SCRIPT>
<BODY>
<input type=text id=txt>
<input type=button id=btn value=check onClick="CheckString()">
</BODY>
</HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
function CheckString(){
var strTmp=document.all.txt.value;
var intTmp=parseInt(strTmp)
if (isNaN(intTmp))
alert("All String");
else if (intTmp==strTmp)
alert("All Numeric");
}
</SCRIPT>
<BODY>
<input type=text id=txt>
<input type=button id=btn value=check onClick="CheckString()">
</BODY>
</HTML>
再判断是否是数字(B)
最后判断是否既有字母又有数字(C)
if(!(!A && !B && C))
{alert(error)}
function check(str){if(!/[A-Za-z0-9]/.test(str))alert('err');}
</script>
<input onchange="check(this.value)" >
function check(str){if(!/^[A-Za-z0-9]*$/.test(str))alert('err');}
</script>
<input onchange="check(this.value)" >
{
if(/[\W_]/.test(str)) alert("有非法字符");
if(str.replace(/\d/g, "").length==0 || str.replace(/[a-z]/gi, "").length==0)
alert("你的输入全是数字或者全是字符!");
}