user184842
user184842

Reputation: 13

Custom validator error not getting displayed

I have grid on the page and text box inside its one of the column as item template. I have used custom validator's clientValidationfuntion to validate the text entered on the Text box.

The javascript function which I used in ClientValidationFunction is properly called, also its setting the

args.isvalid = false

inside the javascript function but the error mesaage is not being displayed on the page.

Both the grid and custom validator controls are inside the same Update Panel control.

Please suggest what could be the problem.

Upvotes: 0

Views: 566

Answers (1)

Nilish
Nilish

Reputation: 1076

You have two options here

Option 1

Go to the View Source and check how the complete ID is being rendered. Now in the JavaScript function write the below code.

document.getElementById('CompleteValidatorID').style.display = 'none';

Option 2

Set ClientIDMode = "Static"

Mark UP

<asp:CustomValidator ID="cmp" runat="server" ClientIDMode="Static" ErrorMessage="hello"></asp:CustomValidator>

JavaScript Code

document.getElementById('cmp').style.visibility = "visible";
document.getElementById('cmp').innerHTML = 'Error!';

Upvotes: 1

Related Questions