JS in the page according to the number of changes in total Price and button for format verification

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.