添加购物车按钮上的网页警报消息

Webpage alert message on add cart button

如果未在表单中选择尺寸或颜色单选按钮,我想在我的网页中显示一条警告消息。有谁能够帮助我?我尝试了一些但没有奏效。请参阅下面我的代码:

<div id="Form"><form method="POST" autocomplete="off" title="Product">     
  <input name="title" type="hidden" id="title" value="0">
  <br>
  <p name="cor">
    <strong>
    <label><br>Color:</strong></span><br>
    </label>
    <label><input type="radio" name="cor" value="white" id="cor_0">
      White</label></p>
    <p name="Size">
    <label><br>Size:<br></label>
    <label><input type="radio" name="size" value="22" id="22" onclick="setShoppingCartUrl(this)">
      M</label>
    <label><input type="radio" name="size" value="23" id="23"     onclick="setShoppingCartUrl(this)">
      G</label>
    </strong></p>
  <p><br></p>
<script>
 baseurl = 'cart2.php?add=';
function setShoppingCartUrl(e) {
document.getElementById('shoppingcart').href=baseurl+e.value
}
</script></div>
<div><script>
function setShoppingCartindexUrl()
if (value < 20) {
    alert('<?php echo "Please select your size"; ?>');
         }
    else {
    href="cart2.php?add=."
    }   </script>
<a id="shoppingcart" onclick="setShoppingCartindexUrl()" target="_self"><img      src="images/carrinho01.jpg" alt="noiva em detalhes" width="100%" height="100%"       align="rigth" margin-right="8%"/></a>
</div>
</form>

经过一些研究,我找到了我需要的东西,所以在我的代码下面实施后...

<script>
function validateForm() {
var x = document.forms["myForm"]["size"].value;
if (x == null || x == "") {
    alert("Querida cliente, favor selecionar o tamanho desejado antes de adicionar ao carrinho.");
    return false;
}
else {
        href="cart2.php?add=."
    }}
</script>
<a id="shoppingcart" onclick="validateForm()" target="_self"><img src="images/carrinho01.jpg" alt="noiva em detalhes" width="100%" height="100%" align="rigth" margin-right="8%"/></a>