HTML表单"占位符"在IE 8中不起作用

Tom*_*Tom 3 html forms html5 internet-explorer placeholder

嗨,我已在我的网站上创建了一个表单.我正在使用,placeholder="Full Name"但在IE8(可能还有其他IE版本)中查看时,没有任何内容出现在表单中

我尝试过使用,value="" onfocus="if (this.value == 'Full Name') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Full Name';}"但表格仍然是空的.出于某种原因,当您单击表单时会显示"全名",然后将其关闭.

我正在研究的网站是[usspcatalystcentre.org.uk] [1],你可以看到我的意思.前两个表单(标题和全名)是我尝试过的地方

value="" onfocus="if (this.value == 'Full Name') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Full Name';}" 
Run Code Online (Sandbox Code Playgroud)


表格的其余部分是我刚刚使用过的地方 placeholder

这是我正在处理的实际代码

<form action="contact.php" method="post">


                <input id=title name=title type=text value="" onfocus="if(this.value=='Username') this.value='';" onblur="if(this.value=='') this.value='Username';" required class="top-formfields" value='<?php print $_SESSION['title']?>'>  <br /><br />
                <input id=fullname name=fullname type=text value="" onfocus="if(this.value=='Full Name') this.value='';" onblur="if(this.value=='') this.value='Full Name';" required  class="top-formfields" value='<?php print $_SESSION['fullname']?>'> <br /><br />
                <input id=companyname name=companyname type=text placeholder="Company Name" required  class="top-formfields" value='<?php print $_SESSION['companyname']?>'>    <br /><br />
                <input id=companynumber name=companynumber type=text placeholder="Company Registered Number" required  class="top-formfields" value='<?php print $_SESSION['companynumber']?>'> <br /><br />
                <textarea id=address name=address rows=5 placeholder="Address" required class="top-textarea"><?php print $_SESSION['address']?></textarea> <br /><br />
                <input id=postcode name=postcode type=text placeholder="Post Code" required  class="top-formfields" value='<?php print $_SESSION['postcode']?>'>    <br /><br />
                <input id=phonenumber name=phonenumber type=text placeholder="Phone Number" required  class="top-formfields" value='<?php print $_SESSION['phonenumber']?>'>    <br /><br />
                <input id=email name=email type=text placeholder="Email" required  class="top-formfields" value='<?php print $_SESSION['email']?>'> <br /><br />
                <input id=mobile name=mobile type=text placeholder="Mobile" required  class="top-formfields" value='<?php print $_SESSION['mobile']?>'> <br /><br />
                <input id=website name=website type=text placeholder="Website URL" required  class="top-formfields" value='<?php print $_SESSION['website']?>'> <br /><br />
Run Code Online (Sandbox Code Playgroud)

先谢谢你,汤姆

Zol*_*oth 6

placeholder属性是一种新的HTML5改进.旧的IE-s不支持它 - http://diveintohtml5.info/forms.html

要模仿跨浏览器,您可能希望使用jQuery - 示例