• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation

 
prakash muthu
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Pals,
I have two text fields. Both having onblur event. I have some validation code for both field. while pressing the tab from first column, its doing the validation as well as its going to second column. My problem is, if its any error, the control should not go to second column.
TIA
with regards
Prakash
(prakashem@rediffmail.com)
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you want to do is that after the user leaves the text box, check that value to make sure it is ok. If it is then you let it go, if not then you have an alert box followed by a focus() method that returns the user back to the original text box. I would also select the text in the text box so they can edit it easily. The code would be:
form.email.focus();
form.email.select();
Where form is a variable of the document.form_name and email is the name of the text box being checked.
Bill
 
prakash muthu
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill,
What you said is exactly correct. But if it is any error i'm getting alert message and the control is going to second field then only its coming back to first field because of focus() and select().
so the second field onblur method also get activated. that's why i want to control it.
i think now you will have clear idea about the problem.
-Prakash
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic