如何在ClientValidationFunction上获取'controlToValidate'属性? [英] How to get the 'controlToValidate' property on ClientValidationFunction?

查看:113
本文介绍了如何在ClientValidationFunction上获取'controlToValidate'属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我有这段代码。

Lets say I have this code.

<asp:TextBox ID="TextBox1" runat="server" />

<asp:CustomValidator ID="CustomValidator1" runat="server"
    ClientValidationFunction="ValidationFunction1"
    ControlToValidate="TextBox1"
    Display="Dynamic" />

还有一个验证功能:

function ValidationFunction1(sender, args)
{
}

我想知道是否可以在该函数内让Control验证以下内容:

And i would like to know if, inside the function I could get the Control to validate something like:

var v = sender.ControlToValidate;


推荐答案

实际上 sender.controltovalidate 给出控件的 ClientID 。因此,这似乎是一个解决方案。

Actually sender.controltovalidate gives the ClientID of the control. So this seems like a solution.

function ValidationFunction1(sender, args){
    var v = document.getElementById(sender.controltovalidate);
}

我尝试过并且对我有用。请通知它是否有效。

I tried and it worked for me. Please notify if it works.

这篇关于如何在ClientValidationFunction上获取'controlToValidate'属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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