1.csdn论坛里右上角的搜索栏的textbox效果该如何写,有默认文字,鼠标点击后默认文字消失,可以任意输入,鼠标移开后,再放上去,输入的文字依旧存在。请教!
2.如何判断注册时填写的邮箱有没有@?

解决方案 »

  1.   

      首先文本框有默认值 在js里面定义一个isfirst=true   当用户第一次onclick的时候设置他的value=""
      同时把isfirst=false 
       isfirst=true;
       function click(){
         if(isfirst){
           document.getElementById("t").value=""; 
           isfirst=false;
        }
       }      <input id="t" type="text" onclick="click();" value="也许这里有你想要的答案">   大概就是这样了  代码没验证的··不太记得单词额··
      

  2.   

    <input name="key" id="key" type="text" class="key" value="这里也许就有你要的答案" size="45"
                                onfocus="if(value=='这里也许就有你要的答案') value='';" />
      

  3.   

     return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail)); 
      

  4.   

    1.
    function click(frm){
        if (frm.tt.value="也许这里有你想要的答案"){
           frm.tt.value=="";
        } 
    }<form name="form1">
     <input name="tt" type="text" onclick="click(this.form);" value="也许这里有你想要的答案"> 
    </form>
    2. 用
    var dd = "ddddd";
    dd.indexOf("@") > 0说明包含'@' 
      

  5.   

    1.function clearText()
    {
    document.forms[0].key.value = "";
    document.forms[0].key.focus();
    }
    <form action="search.do" method="post" target="main">
    <input type="text" name="key" onclick="clearText();" />
    <input type="submit" value="搜索" onclick="return checkForm();"/>
    </form>
    2.
    正则表达式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*