Link to home
Start Free TrialLog in
Avatar of bemara57
bemara57

asked on

Custom Validator and Client-Side function question

I have a custom validator that checks the "ControlToValidate" input text against a javscript function. This is what I have so far:

                <asp:TextBox ID="createFileText" runat="server" />
                <asp:CustomValidator ID="CustomValidator1" runat="server"
                    ErrorMessage="Some error, try again."
                    ClientValidationFunction="CheckFileExists"
                    ControlToValidate="createFileText" />

JS Function:
function CheckFileExists(sender, args)
{ ?? alert(sender.ControlToValidate) ?? }

In the javscript function, I'm trying to get the name of the ControlToValidate from the sender, expecting "createFileText" back. I tried sender.ControlToValidate but got an undefined error. Is this possible?
ASKER CERTIFIED SOLUTION
Avatar of FlorinAntoci
FlorinAntoci
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bemara57
bemara57

ASKER

Thanks, but it turned out to simply be sender.controltovalidate. Found out using your method :)