Client side validator reset?

P

Paul

How do you clear a validation control on the client?
I have a clear button which clears the input boxes, but if any validation
controls have fired, their text isn't cleared. I looked around for a long time
for an answer but found nothing. Has to be cleared on the client with no postback.
 
G

Guest

It sounds like you just want to clear the text of the validation control. If
that's the case, you want to write a javascript routine similar to this (I
apologize if innerHtml isn't the name of the property, but you'll get the
idea):

function clearValidation ()
{
document.getElementById("ValidatorControlName").innerHtml = '';
}

You will then want to call this method on whatever event you're handling
that is supposed to clear this. If a simple button click:

<input type="button" onClick="js:clearValidation()">
 
H

HockeyFan

You can also call ValidatorEnable(validatorname, false);

false turns the validator off. True turns it back on.
 
P

Paul

That was the first thing I tried and it doesn't work, nor does innerText.

document.getElementById("RequiredFieldValidator2").innerHtml = '';

Validation control as rendered -- with visibility:hidden? It still shows up on
the page.

<span id="RequiredFieldValidator2" style="color:Red;visibility:hidden;">File
Name cannot be empty.</span>
 
P

Paul

Ok, now it's working as:

document.getElementById("RequiredFieldValidator2").innerHtml = '';

I made no changes but now it works. ValidatorEnable also works. I am trying to
do too much client side on this page, I think I will have to go to codebehind
and separate pages.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top