<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>忘记密码</title>
<link rel="stylesheet" type="text/css" href="../css/background.css" />
<link rel="stylesheet" type="text/css" href="../css/cell_reg.css" />
<script src="../js/jquery.min.js" type="text/javascript"></script>
</head>
<script language="javascript">
 $(function(){
     $("#cardid").blur(function(){//用户名文本框失去焦点触发验证事件
       if($(this).val =null || !$(this).val.match(/^\d{18}$/))//验证不能为空并且18位数字
        {s
 $("#nameTip").html("卡号不能为空或只能为18位数字");
        }
        else
        {
            $("#nameTip").html("输入正确");
        }
});
  <tr align="center">
<td class="tdsty1" >卡&nbsp;&nbsp;号:<td>
<td class="tdsty2" ><input type="text" name="cardid" id="cardid" /><span id="nameTip"></span></td>
</tr>

解决方案 »

  1.   

    jquery 新手,if判断哪里有错误? 
      

  2.   

    少了()  if($(this).val() =null || !$(this).val().match(/^\d{18}$/))//验证不能为空并且18位数字
      

  3.   

    少了一个"="
    if($(this).val==null || !$(this).val.match(/^\d{18}$/))//验证不能为空并且18位数字
      

  4.   

    少= , val后面少()JQUERY 对象 一般没有属性,大多数操作成员都是方法.除了你自己加的.
    例如  width(), height() ,offset().left 
      

  5.   

            {s
         $("#nameTip").html("卡号不能为空或只能为18位数字");大哥 。。你这s是想肿么了,想干什么ctrl+s的时候注意点
      

  6.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     <head>
      <title> New Document </title>
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
     </head>
     <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript">
    $(function(){
    $("#cardid").blur(function(){

    var val=$(this).val();
    // alert(val);

    if(val.length==0||val.length!=19){
    alert("The text is wrong!");
    }else{
    alert("OK");
    }
    });

    });</script>
     <body>
    <!--<embed width="100%" height="100%" name="plugin" src="C:\Users\MKW\Desktop\Oracle Concepts (10g R2) 中文版.pdf" type="application/pdf">-->
    <input type="text" id="cardid"/>
     </body>
    </html>
      

  7.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>忘记密码</title>
    <link rel="stylesheet" type="text/css" href="../css/background.css" />
    <link rel="stylesheet" type="text/css" href="../css/cell_reg.css" />
    <script src="../js/jquery.min.js" type="text/javascript"></script>
    </head>
    <script language="javascript">
     $(function(){
         $("#cardid").blur(function()    //用户名文本框失去焦点触发验证事件
          {
            if($(this).val() == null || !$(this).val().match(/^\d{18}$/))//验证不能为空并且18位数字
            {
                $("#nameTip").html("卡号不能为空或只能为18位数字");
            }
           else
            {
                $("#nameTip").html("输入正确");
            }
          });
    });
    </script>
    <body style='width:300px;height:300px;background:gray'>
    <table style='width:200px;height:50px;border:1px solid red'>
    <tr align="center">
            <td class="tdsty1" >卡&nbsp;&nbsp;号:<td>
            <td class="tdsty2" ><input type="text" name="cardid" id="cardid" style='width:100px;height:20px'/><span id="nameTip"></span></td>
        </tr>
    </table>
    </body>
    </html>