Click to See Complete Forum and Search --> : Java Script - onBlur event goes infinite message
sarath_777
Dec 14th, 2000, 07:25 PM
I have a web page that need validation of input data ..
and i have used onBlur event that calls ValidateField
that checks whether the length of entered data in that
field is greater than certain value(say 3 chars)..
<INPUT NAME="FirstName" TYPE=TEXT SIZE=15 onBlur="validateField(this,3);" >
function ValidateField(field,len)
{
if (field.length < len)
{
alert("Field must be at least " + minLen + "
characters long!");
field.focus();
}
}
But, the problem is, the message keeps coming
infinitely if less characters, say 2 chars is entered..
It goes into infinite message display and it
Is it a browser problem ?
thanks
sarath
Mark Sreeves
Dec 15th, 2000, 03:23 AM
I'll tell you what the problem is...
you have more than one textbox on your page and you are calling validateField onBlur of both/all of them.
When you enter text in the box 1 and then go to box 2 box one is being validated. setting the focus to box 1 causes box 2 to be validated which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated,which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated,which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated,which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated,which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated,which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated,which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated,which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated,which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated,which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated,which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated,which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated,which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated,which then sets focus to box 2 causing box 1 to be validated, which then sets focus to box 1 causing box2 to to be validated
...and so on!
sarath_777
Dec 15th, 2000, 06:00 AM
hi mark,
You are perfectly right in saying that two
text boxes are using this valid function.. i tried
writing separate functions and calling them.. Still
nothing happened.. the problem persists..
I tried inserting a dummy text box in between these
successive text boxes .. Still the problem persists..
Is there any way out ??
thanks once again..
sarath
Mark Sreeves
Dec 15th, 2000, 06:14 AM
It would (probably) be better to do all you field checking last of all.
Is the form going to be posted back to the server? if so, check all the fields before submiting.
sarath_777
Dec 15th, 2000, 09:08 AM
hi mark,
thanks..
It is better to check the validations
at the end ..
sarath
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.