Javascript Quickie

C

Craig G

i have a custom validator control that fires on the text changed event of a
field, but the validator wont fire when the field is blank, so i was looking
at using a bit of clientside script.

i not the hottest at Javascript, so i was wondering how i would go about
checking if a field has been populated and if then then returning the focus
to that field if it hasnt

Cheers,
Craig
 
C

Craig G

would it be possible to add it in as an attribute on that field?

txtCsa_No.Attributes.Add("onblur", "then do a field length check and return
the focus if less than 0??;")
 
H

Hans Kesting

Craig said:
would it be possible to add it in as an attribute on that field?

txtCsa_No.Attributes.Add("onblur", "then do a field length check and return
the focus if less than 0??;")

Be careful with "onBlur" in combination with setting focus:
you might end up with two fields combatting for the focus
and blocking the browser:
fieldA isn't correct and pulls the focus
to it, which fires the onBlur for fieldB. FieldB isn't satisfied
either so pulls the focus to itself, thereby firing the onBlur
for fieldA and starting the loop again. Been there, done that :)
 
C

Craig G

should be ok that way as this field is the only field that has an onblur
event

any idea's on what i need to write into the string in the attribute?

Cheers,
Craig
 

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,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top