开发者

How to Make the RequiredField Validator visible

开发者 https://www.devze.com 2022-12-20 14:19 出处:网络
Using javascript or jquery, how can I make a Required Field Vali开发者_StackOverflow社区dator control (of ASP.NET) visible. If we check the viewsource of the Required Field valiator, we can see that t

Using javascript or jquery, how can I make a Required Field Vali开发者_StackOverflow社区dator control (of ASP.NET) visible. If we check the viewsource of the Required Field valiator, we can see that the visibility is false initially. $("#spanReqFieldValidator").show() / fadeIn() wont work.

Any thoughts ?

From googling, I understand that jQuery has some issues with visibility attribute.


You can call the ValidatorValidate() function in javascript to make a validator execute it's validation logic (and show up if necessary). Something like this:

ValidatorValidate(document.getElementById('<%=MyValidator.ClientID%>'));

For more on the client-side validation API, see here.


Try this:

$("#spanReqFieldValidator").css("visibility","visible");

jQuery toggles the display attribute usually, visibility you need to toggle by setting the css. You could spice it up a bit as well:

$("#spanReqFieldValidator")
  .css({ "visibility":"visible","display":"none"}).fadeIn();
0

精彩评论

暂无评论...
验证码 换一张
取 消