简体   繁体   English

表单所需的属性验证错误

[英]Form required attribute validation error

I'm trying to put the final touches on a site that I'm building and I'm coming up with a validation error that I can't figure out. 我正在尝试将最后的修改放在我正在构建的网站上,并且我想出了一个我无法弄清楚的验证错误。 It involves the use of the "required" attribute in one of my forms. 它涉及在我的一个表单中使用“required”属性。 Here is the form code: 这是表单代码:

<div id="sub">
    <form id="subForm" action="MAILTO:tworley1977@yahoo.com" method="post" enctype="text/plain">
        <label class="floatLabel" for="subBox"><b>ENTER YOUR EMAIL IN THE BOX BELOW TO SUBSCRIBE TO OUR NEWSLETTER</b></label> <br/>
        <input type="text" name="subBox" id="subBox" size="20" required /> <br/>
    <fieldset id="buttons">
        <input type="submit" value="Subscribe" />
        <input type="reset" value="Cancel" />
    </fieldset>
    </form>
</div>

I'm using a transitional doctype. 我正在使用过渡文档类型。

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

Checking with W3C Markup Validator; 使用W3C标记验证器进行检查; this is the error that keeps coming up: 这是不断出现的错误:

Line 116, Column 69: "required" is not a member of a group specified for any attribute 第116行,第69列:“required”不是为任何属性指定的组的成员

        <input type="text" name="subBox" id="subBox" size="20" required /> <br/>

This is the only error that I'm getting, but as near as I can tell, I'm using the required attribute correctly. 这是我遇到的唯一错误,但就我所知,我正确使用了必需的属性。 It renders correctly in the browser and works as expected. 它在浏览器中正确呈现并按预期工作。

Any thoughts as to why I'm getting this validation error?? 有任何想法为什么我得到这个验证错误? Thanks. 谢谢。

The required attribute is an HTML5 attribute and not allowed according to older HTML specifications, such XHTML 1.0. required属性是HTML5属性,根据较旧的HTML规范(例如XHTML 1.0)不允许使用。

Consider using HTML5 validation instead, using the doctype string 请考虑使用HTML5验证,使用doctype字符串

<!DOCTYPE html>

Beware that HTML5 does not allow all XHTML 1.0 features, especially if you are using XHTML 1.0 Transitional. 要注意的是HTML5 不允许所有的XHTML 1.0的功能,特别是如果你使用XHTML 1.0过渡。

只写< !DOCTYPE html > ,它会起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM