Checkboxes & Custom Buttons

Discussion in 'JavaScript' started by mphilips, Nov 2, 2008.

  1. #1
    Hi, I'm trying to create a simple validation check that forces users to click a checkbox(agreeing to ToS) . The problem I am having is that I use a custom submit graphic.

    I tried simply using the onclick event handler on the custom graphic link but I can only get it to work if I use it on a form submit button.

    Any help :( sorry I am still very new to javascript.

    Thanks
     
    mphilips, Nov 2, 2008 IP
  2. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #2
    For validation always use the form's onsubmit event:
    <form ............. onsubmit="return validator(this)">
    Code (markup):
     
    Logic Ali, Nov 2, 2008 IP
  3. mphilips

    mphilips Peon

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I see..

    but can I simply take the onSubmit = "return validator(this)">

    and stick it like this
    <a href = "http://www.google.ca" onSubmit = "return validator(this)">
    <img src = "imagefile" /></a>
    HTML:
    It works fine if I add a regular submit button, but nothing is happening when i use my custom image as the submit.
     
    mphilips, Nov 2, 2008 IP
  4. Sergey Ten

    Sergey Ten Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi, mphilips

    You should use the image type for input tag :)

    
    <input type="image" src="path_to_your_image" onclick="return validator(this);" />
    
    PHP:
     
    Sergey Ten, Nov 3, 2008 IP