1
I have a field that is filled with an automatic date , this field is validated with customValidator so that the date is not empty, the problem when the field is validated with empty and I click on some control of the page that Postback, the validation is lost. It is possible for each page post the field to be validated by customValidator
Follow the control code:
<asp:Label ID="lblDtInventario" CssClass="FormatacaoTextos" Style="width: 85px; margin-top: 3px;" Text="Dt. Inventário:" runat="server" />
<asp:TextBox runat="server" ID="txtDtInventario" SkinID="CampoData" Style="float: left;"></asp:TextBox>
<asp:CustomValidator runat="server" ID="CustomValidator" ControlToValidate="txtDtInventario" ErrorMessage=" " Display="Dynamic" ClientValidationFunction="ValidarDataInventario" ValidateEmptyText="true" ValidationGroup="vgObrigarCampo"></asp:CustomValidator>
Follow the validator code:
function ValidarDataInventario(src,args) {
args.IsValid = document.getElementById("ctl00_ContentPlaceHolder1_txtDtInventario").value == "" ? false : true;
};
you are using updatepanel?
– RBoschini
I’m not using the updatepanel
– krispim
Friend does so, changes Validateemptytext="true" to false and controls the validation only in your Function JS.
– RBoschini
Rboscini, his suggestion did not work, now he stopped doing the validation by switching from true to false. thanks for the tip.
– krispim