javascript里的一些问题 1.csdn论坛里右上角的搜索栏的textbox效果该如何写,有默认文字,鼠标点击后默认文字消失,可以任意输入,鼠标移开后,再放上去,输入的文字依旧存在。请教!2.如何判断注册时填写的邮箱有没有@? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 首先文本框有默认值 在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="也许这里有你想要的答案"> 大概就是这样了 代码没验证的··不太记得单词额·· <input name="key" id="key" type="text" class="key" value="这里也许就有你要的答案" size="45" onfocus="if(value=='这里也许就有你要的答案') value='';" /> return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail)); 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说明包含'@' 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+)* 求救,调用GetStringUTFChars导致JVM crash httpclient如何抓取网页的完整信息 struts框架get方法提交的问题 POI操作word的问题 Tomcat端口改成80后,JSP编译后的文件放在哪里了? 还没解决的JXL问题?高手快进100分!急求 如何实现自动后退??? struts2 问题 这个错误提示谁能帮我解决 #javax.servlet.ServletException:Servlet execution threw an java操作数据库的问题 iReport能直接给结果集出现结果么
同时把isfirst=false
isfirst=true;
function click(){
if(isfirst){
document.getElementById("t").value="";
isfirst=false;
}
} <input id="t" type="text" onclick="click();" value="也许这里有你想要的答案"> 大概就是这样了 代码没验证的··不太记得单词额··
onfocus="if(value=='这里也许就有你要的答案') value='';" />
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说明包含'@'
{
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+)*