2012-04-24 63 views
1

我已经创建了一个RSS提交表单,并且我想在输入框中显示类似Enter your email here....的内容,并且当他们点击它时,该消息应该消失,并且他们可以将他们的电子邮件置于框中。提交表格中的值

这里是我使用的那一刻

<div id="RSS"> 
     <form action="http://feedburner.google.com/fb/a/mailverify" class="RSS" method="post" target="popupwindow" onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=RSS', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true"> 
      <input type="hidden" name="uri" value="RSS"> 
      <input type="hidden" name="loc" value="en_US"> 
      <input name="email" id="RSS-text" type="text" maxlength="100" style="width:160px !important" value="Enter your email address..." class=""><button type="submit" id="RSS-button">Subscribe</button> 
     </form> 
    </div> 

的问题是,当有人点击它,它不会消失的代码,我看到了许多形式,包括我的搜索形式是可以做到的那样。

回答

2

您可以使用占位符属性,但它不支持IE:

<input type="text" placeholder="Enter your text here..." /> 

否则,你可以使用一些JavaScript:

<input type="text" onfocus="if(this.value=='Enter your text here...') this.value='';" onblur="if(this.value=='') this.value='Enter your text here...';" value="Enter your text here..." /> 
+0

太谢谢你了! – Ali 2012-04-24 22:45:54