var a;
typeof( a) == 'undefined' || a == null

解决方案 »

  1.   

    谢谢楼上的!
    我晕了,作论坛时为了在某字段值为null时,用其它的字符输出,而不是输出成null
    如 rs 是记录集,要测试的字段是rs(3),
    我这样测试
    if(rs(3)==null) Response.Write("空值");
    本来在其它语句中用 rs(3),就取得了该字段的值了,可是用上面的语句测试就是不行,整了我很久,最后我改成这样
    if(rs(3).value==null) Response.Write("空值");
    嘿,它就可以用了,不懂是何道理.
      

  2.   

    Response.Write不是ASP的吗?JS也有吗?
      

  3.   

    <script>
    function CheckForm()
    {
    for(iIndex=0;iIndex<document.forms[0].elements.length;iIndex++)
    {
    if(document.forms[0].item(iIndex).tagName=="INPUT")
    {
    if(document.forms[0].item(iIndex).type=="text")
    {
    if(document.forms[0].item(iIndex).value=="")
    {
    return false;
    }
    }
    }
    }
    return true;
    }
    </script>
    <form>
    <input type=text id="T1" value="">
    <input type=text id="T2" value="">
    <input type=text id="T3" value="">
    <br>
    <input type=button id="B1" value="效验" onclick="if(!CheckForm()){window.confirm('存在NULL')}">
    </form>
      

  4.   

    你的代碼是ASP的﹐怎么問的是JAVASCRIPT的問題?
      

  5.   

    <html>
    <head>
    <script>
    function IsNull()
    {
      if(event.srcElement.value.length==0)
    {

    alert("null is forbidden!");
    //alert(event.srcElement.id+" is checking");
    event.srcElement.focus();
    alert("OK")
     }
     return;
    }
    </script>
    </head>
    <body>
    <input type="text" name="s1" id="s1"  onfocus="IsNull()">
    <input type="text" name="s2" id="s2"  onfocus="IsNull()">
    </body>
    </html>
    这是你要的代码?