camdav72 0 Posted January 19, 2012 Report Share Posted January 19, 2012 I am needing to include a check box at the bottom of my payment form to be sure that users have read my terms and conditions. I have seen it hundreds of times on various websites. The user cannot complete sale unless they check the box. Is this an easy thing to code? Thanks in advance guys Cammie Quote Link to post Share on other sites
dsonesuk 925 Posted January 19, 2012 Report Share Posted January 19, 2012 you almost basically use the same script here http://www.w3schools.com/jsref/prop_checkbox_checked.asp you check if checked is true, if it is use return true; else return false; instead, the latter prevents the form being submitted. 1 Quote Link to post Share on other sites
camdav72 0 Posted January 19, 2012 Author Report Share Posted January 19, 2012 Sound mate - thanks for your help. Quote Link to post Share on other sites
camdav72 0 Posted January 19, 2012 Author Report Share Posted January 19, 2012 Ok, I am kinda new to DW and HTML so please bear with me here... I get the whole code part for checking the box but how do I prevent the user from proceeding from page without checking it. I want them to click box to accept terms before they can proceed and click 'purchase'... Quote Link to post Share on other sites
dsonesuk 925 Posted January 20, 2012 Report Share Posted January 20, 2012 <form onsubmit="return check();"> rest of inputs..<input type="checkbox" id="check1" name="check1" /><input type="submit" value="submit"></form> function check() {var valid = true;tc_check = document.getElementById("check1"); if(tc_check.checked!=true){alert("Oops you forgot the T and C")valid = false}return valid;} the onsubmit="return check();" in the form element calls the check function and waits for returned true or false response, if true submit the form, else do not. 1 Quote Link to post Share on other sites
camdav72 0 Posted January 20, 2012 Author Report Share Posted January 20, 2012 Legend mate. Thanks... Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.