Alex Mathew
Alex Mathew

Reputation: 350

Validation message of requiredfieldvalidator is still showing for text box which is filled using javascript

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

Answers (2)

Alex Mathew
Alex Mathew

Reputation: 350

I'm using javascript so after value assigned use validatorEnable function with RequiredFieldValidator ID ValidatorEnable(document.getElementById('<%= _validatorForExeFile.ClientID %>'),true);

Upvotes: 0

VDWWD
VDWWD

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

Related Questions