Javascript Quickie

  • Thread starter Thread starter Craig G
  • Start date Start date
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
 
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??;")
 
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 :-)
 
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
 
Back
Top