使用ASP .NET验证控件进行交叉耦合验证 [英] Cross coupled validation using ASP .NET Validation controls

查看:75
本文介绍了使用ASP .NET验证控件进行交叉耦合验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个用例我本来应该实现一个业务规则来验证一个控件对另一个控件的输入。这里的技巧是两个输入之间有一个arithemetic表达式。

只是为了说明我的要求:

假设有两个字段薪水和贷款。我的要求是输入的贷款金额应少于用户工资的30倍。

即LoanAmount< 30 *工资。

我想使用ComparerValidator但是CompareToValue需要一个字符串!!

如何使用ASP .NET valdation控件实现这个要求?

由于ASP .NET验证具有自动生成客户端脚本的这一很好的功能。我想利用它。



如果ASP .NET验证控件无法实现,有哪些替代方案?

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?

推荐答案





Hi,

<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>


这篇关于使用ASP .NET验证控件进行交叉耦合验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆