Skip navigation
Currently Being Moderated

javascript alert not working, HELP!

Apr 15, 2012 1:40 PM

I have a check box that needs to be tick, if not the javascript kicks in before the page is sent to a new page

 

here is the code

 

<script type="text/javascript">

function validate(form) {

if (!document.AdminDownloads.elease.checked)

{ alert("By ticking this box you agree that you have clearly read this document according to our terms and conditions and agree to digitally sign the document.");

return false; }

return true;

}

</script>

 

 

here is the form

<form name="AdminDownloads" method="post" onsubmit="return validateForm()" action="">

 

<input type="checkbox" name="elease" id="elease" />

 

<a href="eLease.php?recordID=<?php echo $row_Recordset1['userid']; ?>"><input type="image" src="../images/smalldownload.png" width="35" height="35" alt="download" value="submit"/></a>

 

              </form>

 

can anyone see what i am doing wrong

 

thanks in advance

Jon

 
Replies
  • Currently Being Moderated
    Apr 15, 2012 5:25 PM   in reply to Jonathan Fortis

    Please compare your JS with the following

    function validateForm() {

    if (!document.AdminDownloads.elease.checked)

    { alert("By ticking this box you agree that you have clearly read this document according to our terms and conditions and agree to digitally sign the document.");

    return false; }

    return true;

    }

    and the markup with the following

    <form name="AdminDownloads" method="post" onSubmit="return validateForm()" action="">

    <input type="checkbox" name="elease" id="elease" />

    <a href="eLease.php?recordID<?php echo $row_Recordset1['userid']; ?>"><input type="image" src="../images/smalldownload.png" width="35" height="35" alt="download" value="submit"/></a>

    </form>

    Gramps

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 16, 2012 5:50 AM   in reply to Jonathan Fortis

    Personally, I would have place an onClick event on the button instead of an onSubmit event on the form.

     

    Gramps

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 16, 2012 9:04 AM   in reply to Jonathan Fortis

    Is this what you are looking for?

     

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    <script src="http://labs.adobe.com/technologies/spry/includes_minified/SpryValidationCheckbox.js"></script>
    <link href="http://labs.adobe.com/technologies/spry/widgets/checkboxvalidation/SpryValidationCheckbox.css" rel="stylesheet">
    </head>
    
    <body>
    <form action="" method="get">
      <p id="sprycheckbox1">
        <input type="checkbox" name="one" id="one">
        <label for="one">One</label>
        <span class="checkboxRequiredMsg">PLEASE TICK THE BOX ON THE LEFT, By ticking this box you agree that you have agreed to our terms and conditions and agree to digitally sign the document.</span>
      </p>
      <p id="sprycheckbox2">
        <input type="checkbox" name="two" id="two">
        <label for="two">Two</label>
        <span class="checkboxRequiredMsg">PLEASE TICK THE BOX ON THE LEFT, By ticking this box you agree that you have agreed to our terms and conditions and agree to digitally sign the document.</span>
      </p>
      <p><input name="" type="submit"></p>
    </form>
    <script type="text/javascript">
    var sprycheckbox1 = new Spry.Widget.ValidationCheckbox("sprycheckbox1");
    var sprycheckbox2 = new Spry.Widget.ValidationCheckbox("sprycheckbox2");
    </script>
    </body>
    </html>

     

    Gramps

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 16, 2012 5:04 PM   in reply to Jonathan Fortis

    Do you want to hear some good things about Spry?

     

    DMXZone: http://www.dmxzone.com/go?16649, http://www.dmxzone.com/go?16717, http://www.dmxzone.com/go?16966,

    WebAssist: http://www.webassist.com/support/validation-tooltips-for-spry/getting- started-guide/validation-tooltips-for-spry_gsg.php, http://www.justdreamweaver.com/wa-site-assist.html

    Linecraft: http://www.linecraft.com/b2/index.php?p=28&c=1, http://www.linecraft.com/spry-pop-up-dialog/extension.php, http://www.linecraft.com/spry_data_utils/videos/editable-spry-table.ph p, http://www.linecraft.com/spry_data_utils/videos/sending_spry_email.php

     

    The above is just a very small selection of professionals that believe in Spry and a very small selection of their reference to Spry. On occasion, I use will use Webeassist's pre-built PHP solutions as per http://www.webassist.com/php-scripts-and-solutions/. These are full of Spry widgets. They would not risk their name by using Spry if it was no good.

     

    Do you want to use javascript?

     

    Spry is javascript, it is a library of javascript code, ready made for us to use. Not only that, the widgets include the markup, the CSS and the javascript which javascript on its own does not have. Even jQuery, which is also a javascript library, is not as easy to implement as Spry

     

    Do you want to give Spry a go?

     

    Have you tried copying and pasting my code into a new document and have you viewed it in your favourite browser?

     

    Grumps

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 30, 2012 6:45 AM   in reply to Jonathan Fortis
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    <script src="http://labs.adobe.com/technologies/spry/includes_minified/SpryValidationCheckbox.js"></script>
    <link href="http://labs.adobe.com/technologies/spry/widgets/checkboxvalidation/SpryValidationCheckbox.css" rel="stylesheet">
    <style>
    #ErrorZone {
        width: 240px;
        text-align: center;
        position: absolute;
        top: 300px;
        left: 50%;
        margin-left: -120px;
    }
    </style>
    </head>
    
    <body>
    <form id="form" action="" method="post">
      <p id="sprycheckbox1">
        <input type="checkbox" name="one" id="one">
        <label for="one">One</label>
      </p>
      <p><input name="" type="submit"></p>
    </form>
    <div id="ErrorZone"><span class="checkboxRequiredMsg">confirm you have read our terms</span></div>
    <script type="text/javascript">
    var sprycheckbox1 = new Spry.Widget.ValidationCheckbox("sprycheckbox1", {additionalError: 'ErrorZone'});
    </script>
    </body>
    </html>

     

    Gramps

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 30, 2012 7:22 AM   in reply to Jonathan Fortis

    No worries!

     

    I have been there, done that

     

    Gramps

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 12:53 PM   in reply to Jonathan Fortis

    Change the selector  from #ErrorZone to #ErrorZone.checkboxRequiredState .checkboxRequiredMsg as in the following

    #ErrorZone.checkboxRequiredState .checkboxRequiredMsg  {

        color: brown;

        font-weight: bold;

        background: yellow;

        border: 1px solid green;

        padding: 20px;

        width: 240px;

        text-align: center;

        position: absolute;

        top: 300px;

        left: 50%;

        margin-left: -120px;

    }

    Gramps

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 1:40 PM   in reply to Jonathan Fortis

    I think that changing the selector will fix the problem. No need for anything else.

     

    Gramps

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 2:34 PM   in reply to Jonathan Fortis

    Please have a look here http://pleysier.com.au/fortis/

     

    Right click on the page and choose View Source or similar to view the source code.

     

    Gramps

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 3:11 PM   in reply to Jonathan Fortis

    Sorry, you have lost me! I think it best if you upload the relative files and supply a link.

     

    Gramps

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2012 5:52 AM   in reply to Jonathan Fortis

    Have another look at http://pleysier.com.au/fortis/

     

    Gramps

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points