By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,365 Members | 1,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,365 IT Pros & Developers. It's quick & easy.

Any one please help me by seeing this code

P: 29
This is the code i hav written
in this i hav to call the respective functions
whenever i press a tab using onblur function
please help me......................

[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function changePage(newLoc)
nextPage = newLoc.options[newLoc.selectedIndex].value
if (nextPage == "month")
window.alert("Enter MONTH");
function change1Page(newLoc1)
window.alert("Enter DATE");
function change2Page(newLoc2)
window.alert("Enter YEAR");
<form name="demo">
Date Of Birth: <select name="selectedPage"
<option value="month" selected="selected">select month</option>
<select name="selected1Page" onblur="change1Page(document.demo.selected1Page)">
<option value="date" selected="selected">select date</option>
<select name="selected2Page" onblur="change2Page(document.demo.selected2Page)">
<option value="year" selected="selected">select year</option>
Feb 21 '07 #1
Share this Question
Share on Google+
6 Replies

Expert Mod 15k+
P: 16,027
Instead of onblur why not use onchange?
Feb 21 '07 #2

P: 29
Ok thank you
i know the functionality of onchange
just i want to know whether we can go with onblur r not as i hav specified in the code.
Feb 23 '07 #3

Expert Mod 15k+
P: 16,027
Well, should not use onblur which can cause problems (because it might be caused by something other than a tab key press). What you can do instead is detect the tab key by setting the onkeyup event handler. The key code is 9 for tab.

I, however, would suggest that you use onchange instead because it only detects when the user makes a change. You can always make a final check when the user tries to submit the form.

btw, this is when you are using alert boxes. If you are just displaying a string error message next to the element, it might be ok. Note that changing the default behaviour (moving focus to the next element) can cause problems.
Feb 23 '07 #4

P: 29
k thank u for ur suggestion
Feb 23 '07 #5

P: 2,476
i also have that problem ...

a best suggestion i was waiting for === acoder

looootttttt of thanxxxxxxx
Feb 24 '07 #6

Expert Mod 15k+
P: 16,027
Both of you are welcome. Glad it helped you.
Feb 26 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.