javaScript to prevent form submit with 0 value
Hi there,
I noticed, that on my shop site it is possible to put items into the cart, even if their value is at $ 0.
To explain, some of the products require version and/or size selection, and the price of the selection is instantly displayed. So, if no selection is made, the price is at $ 0.00.
Now I am trying to prevent the page from submitting (putting items into the cart), if a necessary selection was not made and the displayed price is still at $ 0.
Having no javaScript training whatsoever, I concocted this from the internet:
<script type="text/javascript">
function checkForm() {
//.....
if (WA_eCart_DisplayMoney($shop, $row_rspricetable['price']); == "0") {
alert("Make a selection");
return false;
}
}
</script>
and
<form action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>" onclick="checkForm();" method="post" name="shop_1_ATC_<?php echo $row_DetailRS1["product_id"]; ?>" id="segufix_1_ATC_<?php echo $row_DetailRS1["product_id"]; ?>" >
... where the "onclick" is the only thing I added, everything else was already there.
Could someone help me out?
:)