2012-04-24 61 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