Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 415
user1665700 Avatar asked Mar 27 '26 05:03

user1665700


1 Answers

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

like image 80
Zo Has Avatar answered Mar 29 '26 17:03

Zo Has