SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Photo Adventurer DebNCgal's Avatar
    Join Date
    Sep 2005
    Location
    Lewisvlle, NC (USA)
    Posts
    300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to Fix the Invalid Code in Button Code?

    This will probably be a breeze for many of you to answer. I'm just not up enough on XHTML to know how to get the code for a button to validate. My website is XHTML 1.0 Transitional. I have a few pages with a button at the bottom which will take the visitor back to the previous page. The button works fine, but the page does not validate.

    The invalidation error reads: Required attribute "action" not specified.
    The error refers to the following code:

    HTML Code:
    <form> <input style="margin-top:10px;color:#102669; background-color:#E2E2E2;" onclick="history.back()" type="button" value="Return to Previous Page" /></form>
    Can anyone assist with this? Will be *much* appreciated. Thanks.

    Deb
    Deb Phillips
    The Photo Gal

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    The form tag requires an action attribute. This usually points to the file the form input data is being sent to, itself or otherwise.
    If you aren't sending any input data anywhere, why use a form tag? That is, why not use "button" instead of "input"?

  3. #3
    Photo Adventurer DebNCgal's Avatar
    Join Date
    Sep 2005
    Location
    Lewisvlle, NC (USA)
    Posts
    300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello, Mittineague --

    I got this code sometime ago from a reference site which gave code to use for going back to a previous page. So that's why I'm using this code, even though it doesn't validate.

    I may not have understood you correctly, but I tried the following, based on what I think you meant:

    I removed the form tags and inserted "button" in place of "input". But this made the button disappear down to a tiny little element.

    Did I completely misunderstand?!
    Deb Phillips
    The Photo Gal

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    There are some syntax differences, i.e, "value". Try something like
    HTML Code:
    <button style="margin-top:10px;color:#102669; background-color:#E2E2E2;" onclick="history.back()">Return to Previous Page</button>

  5. #5
    Photo Adventurer DebNCgal's Avatar
    Join Date
    Sep 2005
    Location
    Lewisvlle, NC (USA)
    Posts
    300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bless you, Mittineague! Thanks for spelling it out! The button looks and functions properly, and the page now validates!

    Thanks for your kind, patient response.

    All the best,
    Deb
    Deb Phillips
    The Photo Gal


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
  •