user1665700
user1665700

Reputation: 512

Custom Validator not firing JavaScript Function (Client-Side) in ASP. Net

<asp:CustomValidator ID="CustomValidator1" runat="server" 
    ErrorMessage="Date must be set" ClientValidationFunction="ValidateDate" 
    ControlToValidate="DropDownList1" Display="Dynamic" class="errorMessage">
</asp:CustomValidator>

This is the custom validator, the client-side function is called ValidateDate.

function ValidateDate(sender, args) {
    args.isValid = false;
}

I wrote this function both in a separate .js file, and in the .aspx file, yet it's not working.

Of course the validation will be bigger, I'm just making a test.

Upvotes: 3

Views: 5323

Answers (1)

Zo Has
Zo Has

Reputation: 13018

You have to set ValidateEmptyText="True|False"property on your validator to validate empty text. MSDN

Upvotes: 7

Related Questions