How to make a HTML form pass w3c test?

Discussion in 'HTML & Website Design' started by misohoni, Sep 24, 2005.

  1. #1
    Was told my html form doesn't pass w3c guidelines for "proper" html. Tried the validator tool on it, but it doesn't parse small amount of html.

    Can anyone suggest a tool?

    Here's my HTML below, looks alright to me:

    <FORM id=s class="v1" name="schina" action="http://www.uncoverchina.com/">
    <table width="125" border="1" cellpadding="0" cellspacing="0" bordercolor="#333333" summary="Uncover China Search Box">
    <tr>
    <td valign="middle">
    <TABLE WIDTH=123 BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0 bgcolor="#FFFFFF">
    <TR>
    <TD COLSPAN=2>
    <input type=hidden name=fr value=searchbox>
    <IMG SRC="http://www.uncoverchina.com/images/box_now.gif" WIDTH=123 HEIGHT=21 ALT="Search Now">
    </TD>
    </TR>
    <TR>
    <TD height="30" COLSPAN=2><img src="http://www.uncoverchina.com/images/box_spacer.gif" width="1" height="1">
    <input type=hidden name=toggle value=1>
    <input name="q" type="text" id=fp size="13" maxlength="65">
    </TD>
    </TR>
    <TR>
    <TD width="50">
    <input type="image" src="http://www.uncoverchina.com/images/box_chop.gif" WIDTH=57 HEIGHT=57 border="0">
    </TD>
    <TD valign="top">
    <input type="hidden" name="ds" value="Search">
    <input type="image" src="http://www.uncoverchina.com/images/box_button.gif" alt="Go" name="go" width="60" height="40" border="0">
    </TD>
    </TR>
    <TR>
    <TD COLSPAN=2>
    <input type="image" src="http://www.uncoverchina.com/images/box_uc.gif" ALT="Uncover China - China Search Directory" WIDTH=125 HEIGHT=12 border="0">
    </TD>
    </TR>
    </TABLE>
    </td>
    </tr>
    </table>
    </FORM>
     
    misohoni, Sep 24, 2005 IP
  2. tandac

    tandac Active Member

    Messages:
    337
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Can you post a link so we can check it out in context?
     
    tandac, Sep 24, 2005 IP
  3. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #3
    Haven't got it in action as it's on a dynamic page, only I've tested it and works ok - just got complaints that it doesn't parse correctly.

    Here's a screenshot of what it should look like
     

    Attached Files:

    misohoni, Sep 24, 2005 IP
  4. Macbert

    Macbert Peon

    Messages:
    27
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Assuming you're using HTML 4.01 doctype the code below will validate using W3C validator.

    There were two problems with the code:
    1. The first table uses bordercolor attribute
    2. Image inputs uses width, height and alt attributes
    These problems can be circumvented using css, i.e. style attributes.

    
    <form id="s" class="v1" name="schina" action="http://www.uncoverchina.com/">
      <table width="125" border="1" cellpadding="0" cellspacing="0" style="border-color:#333" summary="Uncover China Search Box">
        <tr>
          <td valign="middle"> 
            <table width="123" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
              <tr>
                <td colspan="2">
                  <input type="hidden" name="fr" value="searchbox">
                  <img src="http://www.uncoverchina.com/images/box_now.gif" width="123" height="21" alt="Search Now">
                </td>
              </tr>
              <tr> 
                <td height="30" colspan="2">
                  <img src="http://www.uncoverchina.com/images/box_spacer.gif" width="1" height="1" alt="">
                  <input type="hidden" name="toggle" value="1">
                  <input name="q" type="text" id="fp" size="13" maxlength="65">
                </td>
              </tr>
              <tr> 
                <td width="50">
                  <input type="image" src="http://www.uncoverchina.com/images/box_chop.gif" style="width:57px;height:57px;border:none;">
                </td>
                <td valign="top"> 
                  <input type="hidden" name="ds" value="Search">
                  <input type="image" src="http://www.uncoverchina.com/images/box_button.gif" style="width:60px;height:40px;border:none;" title="Go" name="go">
                </td>
              </tr>
              <tr> 
                <td colspan="2"> 
                  <input type="image" src="http://www.uncoverchina.com/images/box_uc.gif" title="Uncover China - China Search Directory" style="width:125px;height:12px;border:none;">
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </form>
    
    HTML:
     
    Macbert, Sep 24, 2005 IP
  5. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #5
    Thanks for changing it, works and looks great.

    I did think of using Stylesheets to get around the problem but since I wanted to make the code easy to copy and paste for anyone to put on their sites, I thought it would be better not to ask users to amend their CSS also.
     
    misohoni, Sep 25, 2005 IP