camdav72 Posted January 19, 2012 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 Link to comment Share on other sites More sharing options...
dsonesuk Posted January 19, 2012 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. Link to comment Share on other sites More sharing options...
camdav72 Posted January 19, 2012 Author Share Posted January 19, 2012 Sound mate - thanks for your help. Link to comment Share on other sites More sharing options...
camdav72 Posted January 19, 2012 Author 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'... Link to comment Share on other sites More sharing options...
dsonesuk Posted January 20, 2012 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. Link to comment Share on other sites More sharing options...
camdav72 Posted January 20, 2012 Author Share Posted January 20, 2012 Legend mate. Thanks... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.