hey i have two radio buttons: 'Accept' and 'Don't Accept'

when the form submit button is pressed and the 'Accept' radio is not checked i want the page to reload without sending the info accross...

<form id="form1" name="form1" method="post" action="PaymentFormProcess.php">
    <table width="80%" align="center">
      <tr>
        <td width="43%"><strong>Do you accept these terms and conditions?</strong></td>
        <td width="29%" align="right"><p>
          <label>
            <input type="radio" name="TermsConditions" value="Accept" id="TermsConditions_0" />
            I Accept</label>          
        </p></td>
        <td width="28%" align="right"><label>
          <input type="radio" name="TermsConditions" checked="checked" value="Decline" id="TermsConditions_1" />
          I do not Accept</label>
        </td>
      </tr>
</table>
    <label for="ConfirmBooking">Confirm Booking:</label>
            <input type="submit" name="ConfirmBooking" id="ConfirmBooking" value="Confirm Booking" onclick="Accept()" />      
    </form>
function Accept()
{	
	if(!document.getElementById('TermsConditions_0').checked == true)
	{
		alert("You must Accept terms before booking can be made");
		//window.location.reload(true);//window.location.reload(); 
		window.location.href= 'http://Payment.php';//window.location.href
	}
}

none of the above work as it keeps on sending the form and going to next page...

can anyone help???????????

why not simply check in php whether the radio button is clicked or not, if not clicked then do nothing and show an error msg, if clicked then do some processing/go to the next page.

You can easily send a new header to the browser, which is done by the Function "header".
This will Refresh the Page after one Second and redirect the user to "wherever.php"

header( "refresh:1;url=wherever.php" );

Also the "Location" will work. this just redirects to a new location:

header("Location: wherever.php");

Hope this Helps!
tell me if so xD

use button element instead of submit.
Then your js function will run.

<form id="form1" name="form1" method="post" action="PaymentFormProcess.php">
    <table width="80%" align="center">
      <tr>
        <td width="43%"><strong>Do you accept these terms and conditions?</strong></td>
        <td width="29%" align="right"><p>
          <label>
            <input type="radio" name="TermsConditions" value="Accept" id="TermsConditions_0" />
            I Accept</label>          
        </p></td>
        <td width="28%" align="right"><label>
          <input type="radio" name="TermsConditions" checked="checked" value="Decline" id="TermsConditions_1" />
          I do not Accept</label>
        </td>
      </tr>
</table>
    <label for="ConfirmBooking">Confirm Booking:</label>
            <input type="button" name="ConfirmBooking" id="ConfirmBooking" value="Confirm Booking" onclick="Accept()" />      
    </form>

i used a onsubmit in form tag to return a false/true value. took away the onclick="" and kept it as a submit input tag...

then it worked...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.