In two parts, the first part is on the page, according to the amount of input tag content, dynamically update the contents of the total price tag, the code is as follows:
<script type= "Text/javascript" > $ (document). Ready (function () { $ ( function () { var quantity = $ ("#iquantity"). Val (); var price = $; var total = Price * quantity; $ ("#atotal"). Text (total); } ); </script>
The other part is the verification of the button, the code is as follows:
1<script type= "Text/javascript" >2$ (document). Ready (function () {3$ ("#btSave"). Click (function () {4 if($ ("#iquantity"). val () = = "") {5Alert ("Please fill in the purchase quantity \rplease fill in the Quantity");6 return false;7 }8 varZZ =/^[1-9]\d*$/;9 varQQ = $ ("#iquantity"). Val ();Ten if(!Zz.test (QQ)) { OneAlert ("Please fill in the correct amount of the purchase, the format is a nonzero positive integer \rplease fill in the correct format for the quantity.a positive an integer in the form of nonzero."); A return false; - } -$ ("#btSave"). Hide (); the varWords = "Please later ..."; -$ ("#F"). html (words);//F is a span label - return true; - }); + }); -</script>
JS in the page according to the number of changes in total Price and button for format verification