2012-07-19 26 views
0

嗨,我正在做一個網站和一個窗體,但Firefox的輸入字段中顯示不需要的文本時,它的值爲空。 在輸入法中使用電子郵件或電話時會發生這種情況。firefox顯示文本,而表單輸入值爲空

 <form action='locatie.php?root=<?php echo $root; ?>' target='_self' method='post' onSubmit='return checkForm()' > 
<table style='width:725px;' id='text' border='1'> 
    <tr> 
    <td colspan='7'></td> 
    </tr> 
    <tr> 
    <td colspan='7' ><hr /></td> 
    </tr> 
    <tr> 
    <td style='width:100px;' ><label for='locatie' >Locatie naam: </label></td> 
    <td style='width:140px;' ><input type='text' name='locatie' id='locatie' value='' placeholder='locatie naam' maxlength='20' size='20' /></td> 
    <td style='width:8 0px;' ><label for='adres' >Adres: </label></td> 
    <td colspan='4'><input type='text' name='adres' id='adres' value='' placeholder='Adres locatie' maxlength='30' size='30'/></td> 
    </tr> 
    <tr> 
    <td><label for='beheer' >Beheerder: </label></td> 
    <td ><input type='text' name='beheer' id='beheer' value='' placeholder='Beheerder naam' maxlength='21' size='20' /></td> 
    <td><label for='tel' >Tel nr: </label></td> 
    <td style='width:140;' ><input type='text' name='tel' id='tel' value='' maxlength='13' size='12' /></td> 
    <td style='width:80px;' >Email:</td> 
    <td colspan='2'><input type='text' name='email' id='email' value=' ' placeholder='Email beheer' maxlength='31' size='20' /></td> 
    </tr> 
    <tr> 
    <td style='vertical-align:top;' ><label for='route' >Route beschrijving: </label></td> 
    <td style='vertical-align:top;' colspan='6'><textarea name='route' id='route' value='' placeholder='Google maps link met route' cols='75' rows='10' ></textarea></td> 
    </tr> 
    <tr> 
    <td colspan='7'>&nbsp;</td> 
    </tr> 
    <tr> 
    <td ><label for='ondergrond' >Ondergrond: </label></td> 
    <td ><select name='ondergrond' id='ondergrond' > 
       <option value='Veld' >Veld</option> 
      <option value='Zaal' >Zaal</option> 
      <option value='Kunstgras' >Kunstgras</option> 
     </select> 
    </td> 
    <td><label for='seizoen' >Seizoen: </label></td> 
    <td><select name='seizoen' id='seizoen' > 
       <option value='Veld' >Veld</option> 
      <option value='Zaal' >Zaal</option> 
     </select> 
    </td> 
    <td colspan='3'></td> 
    </tr> 
    <tr> 
    <td colspan='7'><input type='submit' name='action' id='action' value='Opslaan' /></td> 
    </tr> 
    <tr> 
    <td colspan='7'><hr /></td> 
    </tr> 
</table> 
</form> 

在Firefox中,輸入字段將包含文本「在這裏輸入你的電話號碼」或「在這裏輸入你的電子郵件」,我不想。 有沒有什麼辦法可以防止firefox這樣做,除了添加內容到輸入?

如果添加了整個表單,頁面的其餘部分包含大量只將表單保存到數據庫的php。

+0

請發佈您的更多html代碼 – 2012-07-19 13:07:17

回答

2

您正在設置<input>字段上的placeholder屬性,其目的是在沒有數據輸入的情況下顯示某些內容。

只要刪除該屬性,你會沒事的。

MDN舉例:

佔位

一個暗示什麼可以在控制輸入用戶。佔位符文本不得包含回車符或換行符。此屬性適用於type屬性值爲text,search,tel,url或email的情況;否則會被忽略。

+0

這聽起來合乎邏輯,但他的「佔位符」不包含文本「在此輸入您的電話號碼」;而是包含「nr beheer」。 – feeela 2012-07-19 13:18:16

+0

@feeela從給出的代碼來看,它是輸入字段內唯一的文本來源。 'placeholder'中的字符串實際上看起來有點混亂,所以我認爲它不是原始文本。 – Sirko 2012-07-19 13:20:52

+0

@Maurits基於這些信息,我認爲**必須存在某種價值。也許這個值是由一些JavaScript設置的 - 但肯定不是通過Firefox本身。 – feeela 2012-07-19 13:28:45

0

清除您的Cookie,保存的表單數據和瀏覽器緩存。也禁用JS來查看這是不是罪魁禍首。

如果您還沒有使用它,您可能還想刪除placeholder =「」屬性。

我強烈建議您下載Chris Pederick的「網頁開發工具欄」,因爲從瀏覽器中清除所有這些內容並禁用JS/CSS等與點擊按鈕一樣簡單。適用於Firefox和Chrome。

http://chrispederick.com/work/web-developer/

祝你好運,邁克爾。

+0

Thx的建議我已經有了插件,並嘗試過它。 沒有解決問題,我想我只是做一個JavaScript檢查這2行的形式,並將其刪除。留下一個乾淨的輸入字段。 – Maurits 2012-07-19 15:23:21

1

佔位符是問題,但解決方法是不要將其刪除。在輸入標籤內使用autocomplete =「off」。

+0

如果瀏覽器被配置爲允許瀏覽器根據過去的條目提供一個值,則自動完成允許自動完成。它不會影響被問及這個問題的行爲。 – 2014-02-22 18:32:39

相關問題