引用 CustomValidator 控件中的源控件

发布于 2024-08-01 20:04:29 字数 94 浏览 4 评论 0原文

是否有可能获得对 customvalidator 在 javascript 中“附加”到的文本框的引用?

如果验证失败,我想在文本框周围放置一个红色边框。

Is it possible to get a reference to the textbox that the customvalidator is 'attached' to in javascript?

I want to place a red border around the texbox if it fails validation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧时浪漫 2024-08-08 20:04:29

实际上 chrissr 提供的代码在 Firefox 中不起作用,但可以跨浏览器运行(在 Firefox、Chrome 和 IE7 中测试):

function doValidation(sender, args)
{
    alert(sender.controltovalidate);
}

Actually the code provided by chrissr doesn't work in Firefox, but this works cross-browser (tested in Firefox, Chrome and IE7):

function doValidation(sender, args)
{
    alert(sender.controltovalidate);
}
完美的未来在梦里 2024-08-08 20:04:29

您的 JavaScript 验证函数将有权访问“sender”和“args”参数。 正在验证的控件可以从“发送者”访问,如下所示。

function doValidation(sender, args)
{
    alert(sender.attributes["controltovalidate"].value);
}

Your javascript validation function will have access to "sender" and "args" parameters. The control that is being validated may be accessed from the "sender" as follows.

function doValidation(sender, args)
{
    alert(sender.attributes["controltovalidate"].value);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文