Search code examples
asp.netjavascriptjqueryrequiredfieldvalidator

How to Make the RequiredField Validator visible


Using javascript or jquery, how can I make a Required Field Validator 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.


Solution

  • 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();