Custom Validator needs to reset focus on validated control

K

Karen Grube

Hi!

I have a control on a web page and a custom validator associated with that
control, along with a client side javascript validaton function. The
validation is working well with one exception. I'm trying to keep focus on
that control until the user enters something valid, but I'm having trouble
doing that.

The routine is setting Args.IsValid correctly, and I even had "return
Args.IsValid" as the last line of the routine thinking that if it was false
it would return the user to the control. Then I added the last line of code
right before the end of the function, and it still isn't returning focus to
the control, assuming the controlid is "Textbox1":

function testinput (Source, Args)
(
Args.IsValid = false;
if (Args.Value == "Test")
Args.IsValid = true;

if (Args.IsValid == false)
{
alert("Invalid entry. Please try again.");
document.getElementById("Textbox1").focus();
}
}

I must have something wrong. What do I need to do to return focus to a
control until the user inputs something correct? Oh, and yes I did try using
the document.all and form syntax as well, with no luck.

Am I wrong in thinking that if I set focus in a cusstom validator's
client side routine that it should work? Is there something about the alert
box that messes it up?

Please let me know.

Thanks!
Kaen
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top