你可以定制的客户端标准ASP.NET Web窗体验证器的JavaScript验证? [英] Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators?

查看:154
本文介绍了你可以定制的客户端标准ASP.NET Web窗体验证器的JavaScript验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以定制的客户端JavaScript验证标准ASP.NET Web窗体验证器?

Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators?

例如使用ASP:离开的RequiredFieldValidator服务器端code,但单独使用jQuery突出,例如现场或背景颜色实现自己的客户端通知

For instance use a asp:RequiredFieldValidator leave the server side code alone but implement your own client notification using jQuery to highlight the field or background color for example.

推荐答案

标准的CustomValidator 有一个 <一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidator.clientvalidationfunction.aspx\">ClientValidationFunction属性是:

The standard CustomValidator has a ClientValidationFunction property for that:

<asp:CustomValidator ControlToValidate="Text1" 
                     ClientValidationFunction="onValidate" />

<script type='text/javascript'>
function onValidate(validatorSpan, eventArgs)
 { eventArgs.IsValid = (eventArgs.Value.length > 0);
   if (!eventArgs.IsValid) highlight(validatorSpan);
 }
</script>

这篇关于你可以定制的客户端标准ASP.NET Web窗体验证器的JavaScript验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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