Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello all,
I have a use case were i am supposed to implement a business rule which validates input of a control against another.The trick here is there an arithemetic expression involved between the two inputs.
Just to give a gist of my requirement:
Assume there are two fields Salary and Loan. My requirement is that the loan amount entered should be less than 30 times of the users salary.
i.e. LoanAmount < 30 * Salary.
I thought of using ComparerValidator but the CompareToValue takes a string!!
How can i implement this requirement using ASP .NET valdation controls?
As ASP .NET Validation have this nice feature of automatically generating client side scripts. I want to leverage that.

If its not possible with ASP .NET validation controls , what are the alternatives?
Posted
Comments
Rockstar_ 3-Jun-13 5:50am    
You can write a javascript function to calculate this...

1 solution

Hi,

JavaScript
<pre lang="xml"><script type="text/javascript">
        function validate() {
            debugger;
            var t1 = document.getElementById('t1').value;
            var t2 = document.getElementById('t2').value;
            if (t1 < (30 * t2))

               return  true;

            else
                 return false;

        }

    </script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900