FatalBreeze
02-24-2008, 12:40 PM
Hello!
I've built a form, and in the form there are some inputs.
So, i've built a little function in JavaScript to validate the value of the fields (in this case a radio button):
function checkShipment()
{
if ((document.shipment.Stype[0].checked) || (document.shipment.Stype[1].checked))
return true;
alert("You didn't Fill The Shipment Information!");
return false;
}
And in the HTML part:
<input type="submit" value="Checkout" onclick="checkShipment()">
Now the problem is this, when the submit button is clicked, and the value of the radio button is neither one of the choices, then the alert apperas, but the new page loads, and it advances to the next page.
I want to know, how can i stop the browser from proccessing to the next page in case of errors. Thanks!
I've built a form, and in the form there are some inputs.
So, i've built a little function in JavaScript to validate the value of the fields (in this case a radio button):
function checkShipment()
{
if ((document.shipment.Stype[0].checked) || (document.shipment.Stype[1].checked))
return true;
alert("You didn't Fill The Shipment Information!");
return false;
}
And in the HTML part:
<input type="submit" value="Checkout" onclick="checkShipment()">
Now the problem is this, when the submit button is clicked, and the value of the radio button is neither one of the choices, then the alert apperas, but the new page loads, and it advances to the next page.
I want to know, how can i stop the browser from proccessing to the next page in case of errors. Thanks!