当表单输入值为空时,firefox显示文本

时间:2012-07-19 13:05:10

标签: forms html5 firefox

嗨,我正在创建一个网站并使用表单,但是当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中,输入字段将包含文本&#34;在此处输入您的电话号码&#34;或&#34;在此输入您的电子邮件&#34;我不想要的。 除了向输入中添加内容之外,有没有办法阻止firefox这样做?

如果添加整个表单,页面的其余部分包含很多只将表单保存到数据库的php。

3 个答案:

答案 0 :(得分:2)

您在placeholder字段上设置了<input>属性,只要没有输入数据就会显示其内容。

只需删除该属性即可。

引自MDN

  

<强>占位符

     

向用户提示可以在控件中输入的内容。占位符文本不得包含回车符或换行符。当type属性的值为text,search,tel,url或email时,此属性适用;否则会被忽略。

答案 1 :(得分:1)

占位符是问题,但解决方法不是删除它。在输入标记内使用autocomplete =“off”。

答案 2 :(得分:0)

清除Cookie,保存的表单数据和浏览器缓存。同时禁用JS以查看这是否是罪魁祸首。

如果你还没有使用它,你可能还想删除placeholder =“”属性。

我强烈建议您下载Chris Pederick的“Web开发人员工具栏”,因为从浏览器清除所有这些并禁用JS / CSS等就像单击按钮一样简单。适用于Firefox和Chrome。

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

祝你好运,迈克尔。