views:

318

answers:

2

Hi!

In Aspnet, how to trigger RequiredFieldValidator when a textbox is clicked?

A: 
<asp:TextBox ID="TextBox1" runat="server" onclick="javascript:trig();"></asp:TextBox>

javascript funtion

 function trig() {
        ValidatorEnable(document.getElementById('<%= ValidatorID.ClientID %>'), true);
    }
Muhammad Akhtar
Thank U So Much! It is working........ :-)
Nila
U WelCome......
Muhammad Akhtar
I cannot get the value of that Requiredfieldvalidator through document.getelementbyid. It is in content page. Whether that is the problem? It is not working in my project. As it is working in a simple web page.
Nila
I think you have master page and that's why you are not getting proper ID, you can try using this...
Muhammad Akhtar
document.getElementById('<%= yourValidatorID.ClientID %>')
Muhammad Akhtar
Thanks. It is working.
Nila
Hi! Can u say me the javascript function for validatorDisable??
Nila
A: 

In ajax control toolkit, there is a control called validator callout that will help you to do this, link here http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ValidatorCallout/ValidatorCallout.aspx

tuanvt
Thank u.. Actually My requirement is when clicking the box, that Validatorcallout should be called. For that I need to trigger it.
Nila