SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Queensland Australia
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question javascript and XHTML validation

    Hi All, an old employee wrote some javascript that I am using, but it will not validate as XHTML 1.0 Transitional. What the code achieves is it will clear the input form field, ready for the user to type what they want

    Here is the code:

    line 104: <input name="searchKeywords" type="text" style="width:100px" onFocus="java_script_:document.frmSearch.searchKeywords.value='';" value="Search Here!" size="12" />
    <br />
    <script language="JavaScript1.2" type="text/javascript">
    <!--
    writeEngines() document.frmSearch.dropSearchEngines.selectedIndex = 3;
    // -->
    </script>
    <br />
    Line 113: <input name="btnSearch" type="button" class="buttons" id="btnSearch" onClick="goSearch()" value="Search" />

    The Javascript works, but the W3C XHTML 1.0 validatior comes back with the following errors:

    Line 104, column 74: there is no attribute "onFocus" (explain...).
    ...e="text" style="width:100px" onFocus="java_script_:document.frmSearch.searchK
    ^
    Line 113, column 82: there is no attribute "onClick" (explain...).
    ...***="buttons" id="btnSearch" onClick="goSearch()" value="Search" />
    ^

    I don't have a great knowledge of javascript, and I don't know what is wrong...it does work after all!!!

    Any and all comments are welcome.
    Thanks in Advance.

  2. #2
    One website at a time mmj's Avatar
    Join Date
    Feb 2001
    Location
    Melbourne Australia
    Posts
    6,282
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    In XHTML, all attributes must be in lowercase. onFocus should become onfocus, etc.
    [mmj] My magic jigsaw
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The Bit Depth Blog Twitter Contact me
    Neon Javascript Framework Jokes Android stuff

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Queensland Australia
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Of course.....

    Thanks Thomas.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •