0

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

if the 'Accept' radio is not checked when the form gets submitted i would like the page to reload without sending any info...

<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...

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

3
Contributors
3
Replies
8
Views
6 Years
Discussion Span
Last Post by gchurch
0

Just set type="button"

<input type="BUTTON" name="ConfirmBooking" id="ConfirmBooking" value="Confirm Booking" onclick="Accept()" />

When using input for buttons, use onClick event for type="button" and onSubmit for type="submit"(in this case, the listener must return false for canceling the submit).

Hope it helps.

Edited by AleMonteiro: Misspelling

0

remove onclick from submit button.
in FORM tag use onSubmit="return checkaccept();"

function checkaccept(){
 if(!document.getElementById('TermsConditions_0').checked == true){
 alert("You must Accept terms before booking can be made");
 return false;
}else{return true;}
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.