Reputation: 350
Need to check textbox is empty or not using RequiredFieldValidator, while hitting submit button error message is showing and if we fill the textbox using javascript and then click somewhere else error message is not hiding. If anything type over it and move the cursor that time error message will be hidden.
<asp:TextBox runat="server" ID="txtValue" ClientIDMode="Static" />
<asp:RequiredFieldValidator ID="_validatorForExeFile" runat="server" ControlToValidate="txtValue">
<asp:Image ID="_imgExeFolderName" runat="server" ToolTip="Main executable missing." ImageUrl="~/error.png" meta:resourcekey="_actionExeFolderIconResource" />
</asp:RequiredFieldValidator>
Upvotes: 0
Views: 185
Reputation: 350
I'm using javascript so after value assigned use validatorEnable function with RequiredFieldValidator ID ValidatorEnable(document.getElementById('<%= _validatorForExeFile.ClientID %>'),true);
Upvotes: 0
Reputation: 35514
You can simply force the same result as you would when typing in the TextBox with jQuery change
.
$('#txtValue').val('New Value');
$('#txtValue').change();
Upvotes: 1