[JQuery]表單驗證

兩種表單用兩種方法驗證

表單1

<form action="/TheaterTickets/gift-cards-confirm/ " method="get">

<input type="text" id="Card_Value" name="Card_Value" size="6″/>
<input type="text" id="Quantity" name="Quantity" size="6″/>

<input type="button" value="Add to Cart" id="add_cart" />

</form>

驗證方法:

$(document).ready(function() {

   $("#add_cart").click(function() { 

        if(check_keyin())
            $("form").submit();

    });
});

 

表單2

<form  action="/TheaterTickets/gift-cards-confirm/ " method="get">

<input type="text" id="Card_Value" name="Card_Value" size="6″/>
<input type="text" id="Quantity" name="Quantity" size="6″/>

<input type="submit" value="Add to Cart" id="add_cart" />

</form>

驗證方法:

$(document).ready(function() {

   $("form").submit(function() { 

        if(check_keyin()) return true
        else return false;

    });
});