<script>
   strings="aA123.0字符"
   if(strings.match(/[0-9]/)!=null)
      {alert('含有数字')}
 if(strings.match(/[a-z]/i)!=null)
      {alert('含有字母')}
</script>

解决方案 »

  1.   

    <body>
    <script language="JavaScript">
    function check(str)
    {
    var pattern = /^[a-z\d\u4E00-\u9FA5]+$/i;
    if (pattern.test(str))
    alert("输入正确:只包含中文、字母、数字");
    else
    alert("错误:含有符号")
    }
    </script>
    <input type="text" id="txt" value="">
    <input type="button" onclick="check(txt.value)" value="Check">
    </body>
      

  2.   

    //正则匹配 
    匹配中文字符的正则表达式: [\u4e00-\u9fa5] 
    匹配双字节字符(包括汉字在内):[^\x00-\xff] 
    匹配空行的正则表达式:\n[\s| ]*\r 
    匹配HTML标记的正则表达式:/<(.*)>.*<\/\1>|<(.*) \/>/ 
    匹配首尾空格的正则表达式:(^\s*)|(\s*$)(像vbscript那样的trim函数) 
    匹配Email地址的正则表达式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* 
    匹配网址URL的正则表达式:http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)? 
    以下是例子: 
    利用正则表达式限制网页表单里的文本框输入内容: 
    用正则表达式限制只能输入中文:onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" 
    onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))" 1.用正则表达式限制只能输入全角字符: onkeyup="value=value.replace(/[^\uFF00-\uFFFF]/g,'')" 
    onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\uFF00-\uFFFF]/g,''))" 2.用正则表达式限制只能输入数字:onkeyup="value=value.replace(/[^\d]/g,'') 
    "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" 3.用正则表达式限制只能输入数字和英文:onkeyup="value=value.replace(/[\W]/g,'') 
    "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"