0

Preciso validar um campo TextBox, para quando estiver vazio pintar a bordar indicando que tem algum erro com o campo, estou usando o customValidador mas não esta funcionando.

O código da function.

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

    }

e código do campo para validar.

<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>

Como eu faço para validar um campo vazio com o CustomValidator ?

1 Resposta 1

0

Olá,

Segue o código

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

    }

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .