<form name="form1" >
<input type="text" name="word1">
<input type="button" name="b1" onclick="juge()"
</form><script language="JavaScript">
<!--
function juge()
{
……
这里如何写输入框word1中是否含有“标准”这个字符串呢?
}
//-->
</script>

解决方案 »

  1.   

    <form name="form1" >
    <input type="text" name="word1" id="word1">
    <input type="button" name="b1" onkeyup="juge()"
    </form><script language="JavaScript">
    <!--
    function juge()
    {var t = document.getElementById("word1").value;
                if(t == "标准"){
                    alert("提示");
                }
    }
    //-->
    </script>
      

  2.   


    <input type="text" name="word1" id="word1" />
    function juge()
    {
    if(document.getElementById("word1").value.indexOf("标准")>=0)
    {
    alert("有");
    }else
    {
    alert("无");
    }
    }
      

  3.   

    肯定是2L的答案了. 用indexOf
      

  4.   

    <form name="form1" >
    <input type="text" name="word1" id="word1">
    <input type="button" name="b1" onkeyup="juge()"
    </form><script language="JavaScript">
    <!--
    function juge()
    {var t = document.getElementById("word1").value;
      if(t.indexOf("标准") > -1){
      alert("提示");
      }
    }
    //-->
    </script>
      

  5.   

    有点答非所问了 有个误区:楼主是想要即时型的单击型的。貌似这种验证需要onkeyup而非onclick
      

  6.   

    xx.indexOf("xx")!=-1 就是含有 或者spit("xx")来分割判断
      

  7.   

    顶 indexof  
    楼上说的 split 还是有创意的哈哈
      

  8.   

    if(document.getElementById("word1").value.indexOf("标准")>=0)
    {
       alert("有");
    }else
    {
       alert("无");
    }