tworley1977
tworley1977

Reputation: 311

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

Upvotes: 1

Views: 2038

Answers (2)

Jakubk-0
Jakubk-0

Reputation: 45

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

Upvotes: 0

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201588

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.

Upvotes: 3

Related Questions