<input id="ys">
<button onclick='alert(isNaN(ys.value)?"Not A Number":"Number")'>check</button>

解决方案 »

  1.   

    <script>
    function charTypeAtTest(str){
     alert (isNaN(str)?"非数字":"数字")
     var charType=""
     for(var i=0;i<str.length;i++)  {
        ch=str.substring(i,i+1)
        execScript("c=(ASC('"+ch+"'))","vbscript");
         if (c<0) charType+="中文 "
     if (c<58 && c>48) charType+="数字 "
     if (c<123 && c>96) charType+="小写字母 "
     if (c<91 && c>64) charType+="大写字母  "
     }
     return (charType)
    }
    </script>
    <input type=text>
    <input type=button onclick="alert ('包含:'+'\n'+charTypeAtTest(txt1.value))">
      

  2.   

    <script>
    function charTypeAtTest(str){
     alert (isNaN(str)?"非数字":"数字")
     var charType=""
     for(var i=0;i<str.length;i++)  {
        ch=str.substring(i,i+1)
        execScript("c=(ASC('"+ch+"'))","vbscript");
         if (c<0) charType+="中文 "
     if (c<58 && c>48) charType+="数字 "
     if (c<123 && c>96) charType+="小写字母 "
     if (c<91 && c>64) charType+="大写字母  "
     }
     return (charType)
    }
    </script>
    <input type=text>
    <input type=button onclick="alert ('包含:'+'\n'+charTypeAtTest(txt1.value))">