Contact Form

Discussion in 'HTML & Website Design' started by texanweb, Jul 11, 2012.

  1. #1
    I am trying to W3C validate the following code in my HTML5 file, but its giving me an error message:
    "Line 148, Column 68: The for attribute of the label element must refer to a form control."


    
    <tr>
    <td><label for="Contact_Me_By" id="Contact_Me_By">Please contact me by: *</label></td>
    <td><input type="checkbox" name="Contact_Me_By[]" value="Email" >
    Email<br />
    <input type="checkbox" name="Contact_Me_By[]" value="Phone" >
    Phone </td>
    </tr>
    
    Code (markup):
    What am I doing wrong?
     
    Solved! View solution.
    texanweb, Jul 11, 2012 IP
  2. #2
    You're supposed to put the id in the input, not the label.

    For future reference, whenever I get specific errors I Google them. Pasting "The for attribute of the label element must refer to a form control." into Google brought up a StackOverflow link as the first result, and there's your answer.
     
    mneodor87, Jul 11, 2012 IP
  3. Hostwinds_Dan

    Hostwinds_Dan Active Member

    Messages:
    149
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    That's exactly it. Please fix this and let us know if your problem is resolved! :)
     
    Hostwinds_Dan, Jul 11, 2012 IP
  4. texanweb

    texanweb Active Member

    Messages:
    377
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    58
    #4
    My form is now W3C validated:


    
    <tr>
      <td><label for="Contact_Me_By">Please contact me by: *<br><small>(check all that apply)</small></label></td>
      <td>
            <input type="checkbox" name="Contact_Me_By[]" id="Contact_Me_By" value="Email">Email<br>
            <input type="checkbox" name="Contact_Me_By[]" value="Phone" > Phone<br></td>
    </tr>
    
    
    Code (markup):
     
    texanweb, Jul 13, 2012 IP
  5. businessoftheday

    businessoftheday Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It means you must put your code in form because form can contain the label element.
     
    businessoftheday, Jul 14, 2012 IP
  6. creativewebmaster

    creativewebmaster Active Member

    Messages:
    654
    Likes Received:
    7
    Best Answers:
    4
    Trophy Points:
    78
    #6
    You're supposed to put the id in the input, not the label. this will solve.
     
    creativewebmaster, Jul 14, 2012 IP
  7. Jack_ID

    Jack_ID Peon

    Messages:
    98
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    go see it because I've been there, but not yet
     
    Jack_ID, Jul 14, 2012 IP