1

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. Here is the form code:

<div id="sub">
    <form id="subForm" action="MAILTO:[email protected]" 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; this is the error that keeps coming up:

Line 116, Column 69: "required" is not a member of a group specified for any attribute

        <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.

2
  • does required="" make any difference? Commented Dec 12, 2014 at 18:38
  • adding that simply produces a different error: "there is no attribute 'required'". I do get a little more information with this error though. Would the required attribute not be supported by the transitional doctype for some reason?? Commented Dec 12, 2014 at 18:46

2 Answers 2

3

The required attribute is an HTML5 attribute and not allowed according to older HTML specifications, such XHTML 1.0.

Consider using HTML5 validation instead, using the doctype string

<!DOCTYPE html>

Beware that HTML5 does not allow all XHTML 1.0 features, especially if you are using XHTML 1.0 Transitional.

1
  • Thanks Jukka. Made the needed corrections and it validates as HTML5 now. Ended up removing the XHTML declaration altogether since it didn't support my non-breaking whitespace markups. Commented Dec 13, 2014 at 6:07
0

Write only < !DOCTYPE html > and than it will work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.