Validation for minimum and maximum price using Jquery | ASPMANTRA | Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server AND WCF snippets and tutorial

Validation for minimum and maximum price using Jquery

Introduction: In this article today I will explain how we can validate the minimum and maximum price using Jquery
Validation for minimum and maximum price using Jquery

Description:

Add a webform to project and design the page as given below:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>Validation For Minimum and maximum Price</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>


    <center>
    <fieldset style="width:45%;height:50px">
    <legend>Validation For Minimum and maximum Price:</legend>
       Minimum price:<asp:TextBox ID="minprice" runat="server"></asp:TextBox>
       Maximum price : <asp:TextBox ID="maxprice" runat="server"></asp:TextBox>
        </fieldset>       
    </center>      
    </div>
    </form>
     <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://jqueryvalidation.org/files/dist/jquery.validate.min.js"></script>
<script src="http://jqueryvalidation.org/files/dist/additional-methods.min.js"></script>
<script>
    $("#minprice, #maxprice").change(function (e) {
        var lil = parseInt($("#minprice").val(), 10);
        var big = parseInt($("#maxprice").val(), 10);     
        if (lil > big) {
            var targ = $(e.target);
            if (targ.is("#maxprice")) {
                alert("Maximum price must be greater than Minimum price");
                $('#maxprice').val(lil);
            }
            if (targ.is("#minprice")) {
                alert("Minimum price must be less than Maximum price");
                $('#minprice').val(big);
            }
        }
    });
</script>
</body>

</html>

Run the project and check

Is this article helpful for you?
If yes post your comment to appreciate my work and fell free to contact me. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email. 

Post a Comment

[blogger]

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget