How to validate an empty textBox field with CustomValidator

0

I need to validate a TextBox field, so when it is empty I paint the embroider indicating that it has some error with the field, I am using customValidator but it is not working.

The function code.

function ValidatxtECFNrSerie(src, args) {
        if (args.Value.length > 1) { 
            args.IsValid = true;
        }
        else { 
            args.IsValid = false;
        }

    }

and field code to validate.

<asp:TextBox ID="txtECFNrSerie" runat="server" MaxLength="15" Width="150px"></asp:TextBox>
<asp:CustomValidator runat="server" ID="CustomValidator1" ClientValidationFunction="ValidatxtECFNrSerie" ErrorMessage=" * "   ValidationGroup="vgValidarCampo" Display="Dynamic" ControlToValidate="txtECFNrSerie"></asp:CustomValidator>

How do I validate an empty field with CustomValidator?

    
asked by anonymous 09.12.2015 / 14:38

1 answer

0

Hello,

Follow the code

function ValidatxtECFNrSerie(src, args) {
        if (string.IsNullOrEmpty(args.Value)) { 
            args.IsValid = false;
        }
        else { 
            args.IsValid = true;
        }

    }
    
09.12.2015 / 16:14