iPixel Posted September 24, 2007 Share Posted September 24, 2007 I've got 2 radio buttons... Agreement txt here Agreement txt here Agreement txt here Agreement txt here Agreement txt here Agreement txt here Agreement txt here Agreement txt here Agreement txt here Agreement txt here Agreement txt here Agreement txt here <form action="#" method="POST"> <input type="radio" value="YES" name="agreement">YES <br /> <input type="radio" value="NO" name="agreement">NO <br /> <input type="submit" value="Submit" name="submit" /> </form> No what i want is that unless the "YES" radio button is checked... pop up an alert saying u must agree to continue. the weird thing, ok.. I used function chkAgreement() { alert('You must agree to the terms before you continue'); } but even after you hit OK it just goes to where the action points... confirm('msg') i dont really want to use because i dont want the cancel button there.. just the OK. So how do i prevent the form being submitted unless the YES radio button is selected. Thanks Quote Link to comment Share on other sites More sharing options...
EvanAgee Posted September 25, 2007 Share Posted September 25, 2007 I believe what you need is a conditional in your chkAgreement() function that checks to see if your checkbox is checked. Just off the top of my head, haven't tested it or anything. Then, instead of using a submit button simply tie your button to your JS function and use the JS to submit the form if the appropriate field is checked. function chkAgreement() { if (document.myform.agreement.value=='YES') { document.myform.submit(); } else { alert('You must agree to the terms before you continue'); return false; } } Quote Link to comment Share on other sites More sharing options...
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.