SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Location
    uk
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Stopping me validate my html

    Hi
    I have a script that enables me to show images and the trigger is -
    Code:
    <input type="radio" name="_$Extras" value="0;0;None"  checked onClick=changeExtra('/images/empty.gif')>
    When i try to validate the W3C reports -

    an attribute value must be a literal unless it contains only name characters.
    and goes ahead and says -

    You have used a character that is not considered a "name character" in an attribute value. Which characters are considered "name characters" varies between the different document types, but a good rule of thumb is that unless the value contains only lower or upper case letters in the range a-z you must put quotation marks around the value. In fact, unless you have extreme file size requirements it is a very very good idea to always put quote marks around your attribute values. It is never wrong to do so, and very often it is absolutely necessary.
    Strange thing is, i have a few of the lines, and it picks up on different characters, usually the '(' after changeExtra, but sometimes it picks out the 'a' or the 'r' in changeExtra


    If anyone can shed any light i would be grateful.

    Thanks
    Paul

  2. #2
    SitePoint Wizard Rick's Avatar
    Join Date
    Oct 2002
    Location
    Lancashire, UK
    Posts
    3,847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try: checked="checked" (for XHTML) and onclick="changeExtra('/images/empty.gif');" also add a closing / to the end of the tag (for XHTML)

    What are you trying to validate to? HTML 4.0? XHTML?

    checked="checked" because XHTML requires all given attributes to also have a value, the double quotes around the changeExtra function call because that is the value of the onclick attribute. The closing tag is for XHTML too, XHTML requires that all tags are closed (etiher with a corresponding closing tag i.e. </input> or inline />)

    HTML Code:
    <input type="radio" name="_$Extras" value="0;0;None" checked="checked" onclick="changeExtra('/images/empty.gif');" />
    validates as XHTML 1.0 Strict for me (in the proper context)
    Rick

  3. #3
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Rick
    HTML Code:
    <input type="radio" name="_$Extras" value="0;0;None" checked="checked" onclick="changeExtra('/images/empty.gif');" />
    validates as XHTML 1.0 Strict for me (in the proper context)
    That is only because XML DTDs aren't as expressive as SGML DTDs. The name="" attribute doesn't allow $s. (Well, as written it does in XHTML, but then XHTML also allows tabindex="garbage" and lang="not sure" aswell, even though the HTML4 spec says that tabindex="" has to be a NUMBER and lang="" has to be an RFC1766 language code...)
    Simon Pieters

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Location
    uk
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Rick,

    Sorted!

    Thank you kindly :-)

    Paul

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Location
    uk
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am using an oldish, but VERY flexible javascript shopping basket code (and i'm not going to change it just yet :-)

    This requires the $ and the _ in the name file for specific reasons.

    This doesn't prevent it from validating i'm glad to say!

    There is one line i cannot get through html validation and it must be as it is to work -

    Code:
    <form onSubmit="buy(this);return(false);" name="gift">
    with the w3c saying -

    required attribute "ACTION" not specified.
    If anyone can help me sort that out i'm 100% html validated :-)

    Paul

  6. #6
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    <form action="" onsubmit="buy(this);return(false);" name="gift">
    Simon Pieters

  7. #7
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Location
    uk
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you kindly.

    I never even though of using it blank!

    I feel a bit thick as it's that simple........


    Thanks again

    I'm 100% (well, my html validation is :-)


    Paul


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
  •