Home > front end >  Textarea Label in Form: Error: The value of the for attribute of the label element must be the ID of
Textarea Label in Form: Error: The value of the for attribute of the label element must be the ID of

Time:10-28

I'm in a class where I'm tasked with adding a form to a page and validate the page using w3c html validator. I get the error:

Error: The value of the for attribute of the label element must be the ID of a non-hidden form control.

The error only applies to the label for the textarea element in the form and none of the input elements. Here's the HTML for the form:

<form id="contactForm" class="form-grid"> <!-- Start Form -->
            <fieldset>
                
                <legend>Contact Information</legend>
                
                <label for="contactFirstName">First Name:</label>
                <input type="text" name="contactFirstName" id="contactFirstName">
                
                <label for="contactLastName">Last Name:</label>  
                <input type="text" name="contactLastName" id="contactLastName"> 
                
                <label for="contactEmail">Email:</label>
                <input type="email" name="contactEmail" id="contactEmail">
                
                <label for="contactPhone">Phone:</label>
                <input type="tel" name="contactPhone" id="contactPhone">
                
                <label for="contactMessage">Message:</label>
                <textarea id=“contactMessage” name=“contactMessage” rows="5" cols="35"></textarea>
                
            </fieldset>
            
            <input type="submit"  id="submit"  value="SUBMIT"  class="btn">
        </form>

Thanks in advance for the help.

CodePudding user response:

Check the quotation marks in your <textarea> (expecially the "id" and "name" attributes) ...

  • Related