473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

simple date entry??

I know this should be simple...but for some reason my brain isn't working.

I want my users to enter a the date in three seperate boxes. After the
users enters in two digits for the month I want the cursor to move to the
day textbox and so on....

I was using simple code...but onKeyPress occurs before the value
changes...can anyone help me?

my code:
<form name="frmdateboxes" action="test2.asp" method="post">
<input type="hidden" name="hidBBdate" value="">
<input type="text" name="txtmonth" class="smalltxtbox" maxlength="2"
onKeyPress="checklen(this,2);"> /
<input type="text" name="txtday" class="smalltxtbox" maxlength="2"
onKeyPress="checklen(this,2);"> /
<input type="text" name="txtyear" class="txtbox" maxlength="4"
onKeyPress="checklen(this,4);">
</form>

function checklen(tFormObj, tLen)
{
if (tFormObj.value.length == tLen)
{
document.forms["frmdateboxes"].nextelement.focus();
}
}
TIA
-Bruce Duncan
Jul 23 '05 #1
7 1422

"Bruce Duncan" <bruce~w~duncan@~hotmail.com> wrote in message
news:10*************@corp.supernews.com...
I know this should be simple...but for some reason my brain isn't working.

I want my users to enter a the date in three seperate boxes. After the
users enters in two digits for the month I want the cursor to move to the
day textbox and so on....

I was using simple code...but onKeyPress occurs before the value
changes...can anyone help me?

my code:
<form name="frmdateboxes" action="test2.asp" method="post">
<input type="hidden" name="hidBBdate" value="">
<input type="text" name="txtmonth" class="smalltxtbox" maxlength="2"
onKeyPress="checklen(this,2);"> /
<input type="text" name="txtday" class="smalltxtbox" maxlength="2"
onKeyPress="checklen(this,2);"> /
<input type="text" name="txtyear" class="txtbox" maxlength="4"
onKeyPress="checklen(this,4);">
</form>

function checklen(tFormObj, tLen)
{
if (tFormObj.value.length == tLen)
{
document.forms["frmdateboxes"].nextelement.focus();
}
}
TIA
-Bruce Duncan


It seems to work if I change the function call from onKeyPress to onKeyUp.
Does anyone know of a better way?

-bruce duncan
Jul 23 '05 #2
In article <10*************@corp.supernews.com>,
bruce~w~duncan@~hotmail.com enlightened us with...
I know this should be simple...but for some reason my brain isn't working.

I want my users to enter a the date in three seperate boxes. After the
users enters in two digits for the month I want the cursor to move to the
day textbox and so on....

I was using simple code...but onKeyPress occurs before the value
changes...can anyone help me?


Use onKeyUp, but form.nextelement is not valid in Netscape. Actually, it
didn't work in IE, either. I don't know what you were going for with
that.
However, the event did fire at the proper time, after the value was
changed.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
function checklen(tFormObj, tLen)
{
alert(tFormObj.value);
if (tFormObj.value.length == tLen)
{
document.forms["frmdateboxes"].nextelement.focus();
}
}
</script>
</head>

<body>
<form name="frmdateboxes" action="test2.asp" method="post">
<input type="hidden" name="hidBBdate" value="">
<input type="text" name="txtmonth" class="smalltxtbox" maxlength="2"
onKeyUp="checklen(this,2);"> /
<input type="text" name="txtday" class="smalltxtbox" maxlength="2"
onKeyUp="checklen(this,2);"> /
<input type="text" name="txtyear" class="txtbox" maxlength="4"
onKeyUp="checklen(this,4);">
</form>
</body>
</html>
--
--
~kaeli~
He's your God, they're your rules - you burn in Hell.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #3
"Bruce Duncan" <bruce~w~duncan@~hotmail.com> wrote in message
news:10*************@corp.supernews.com...
I know this should be simple...but for some reason my brain isn't working.

I want my users to enter a the date in three seperate boxes. After the
users enters in two digits for the month I want the cursor to move to the
day textbox and so on....

I was using simple code...but onKeyPress occurs before the value
changes...can anyone help me?

my code:
<form name="frmdateboxes" action="test2.asp" method="post">
<input type="hidden" name="hidBBdate" value="">
<input type="text" name="txtmonth" class="smalltxtbox" maxlength="2"
onKeyPress="checklen(this,2);"> /
<input type="text" name="txtday" class="smalltxtbox" maxlength="2"
onKeyPress="checklen(this,2);"> /
<input type="text" name="txtyear" class="txtbox" maxlength="4"
onKeyPress="checklen(this,4);">
</form>

function checklen(tFormObj, tLen)
{
if (tFormObj.value.length == tLen)
{
document.forms["frmdateboxes"].nextelement.focus();
}
}
TIA
-Bruce Duncan

I should post the code that works...sorry:

function checklen(tFormObj, tLen, tNextObj)
{
if (tFormObj.value.length == tLen)
{
document.forms["frmdateboxes"][tNextObj].focus();
}
}

<form name="frmdateboxes" action="test2.asp" method="post">
<input type="hidden" name="hidBBdate" value="">
<input type="text" name="txtmonth" class="smalltxtbox" maxlength="2"
onKeyUp="checklen(this,2,'txtday');"> /
<input type="text" name="txtday" class="smalltxtbox" maxlength="2"
onKeyUp="checklen(this,2,'txtyear');"> /
<input type="text" name="txtyear" class="txtbox" maxlength="4">
</form>

-Bruce Duncan
Jul 23 '05 #4
Bruce Duncan wrote:


It seems to work if I change the function call from onKeyPress to onKeyUp.
Does anyone know of a better way?

-bruce duncan

If the number is a two digit number, this will not work. In fact I don't
know if there is a way to do what you want, since you don't know when
the user is finished with the entry.
Mick

Jul 23 '05 #5
Lee
Bruce Duncan said:
I want my users to enter a the date in three seperate boxes. After the
users enters in two digits for the month I want the cursor to move to the
day textbox and so on....


That's a very annoying thing for a user interface to do.

Almost every text entry field requires you to hit TAB
afterward. If you change the rules in a few cases
you're not making things any easier.

If you're doing this to prevent mistakes, you're not
helping either. Most of the time that I make a typing
error, I realize it immediately and hit backspace and
then the correct character. If the focus moved to a
new field after I typed the error, by backspace didn't
correct it, and now I have errors in two fields.

I don't like having to slow down and look to see if some
clever programmer is going to make the focus move away
from where I expect it to be.

Jul 23 '05 #6
"Lee" <RE**************@cox.net> wrote in message
news:c8*********@drn.newsguy.com...
Bruce Duncan said:
I want my users to enter a the date in three seperate boxes. After the
users enters in two digits for the month I want the cursor to move to the
day textbox and so on....


That's a very annoying thing for a user interface to do.

Almost every text entry field requires you to hit TAB
afterward. If you change the rules in a few cases
you're not making things any easier.

If you're doing this to prevent mistakes, you're not
helping either. Most of the time that I make a typing
error, I realize it immediately and hit backspace and
then the correct character. If the focus moved to a
new field after I typed the error, by backspace didn't
correct it, and now I have errors in two fields.

I don't like having to slow down and look to see if some
clever programmer is going to make the focus move away
from where I expect it to be.


Good Point Lee...

The more I think about it...the more I agree. Unless the user specifically
asks, I won't use this method.

....but at least I can if I need to..

-Bruce Duncan
Jul 23 '05 #7
JRS: In article <10*************@corp.supernews.com>, seen in
news:comp.lang.javascript, Bruce Duncan <bruce~w~duncan@~hotmail.com>
posted at Mon, 17 May 2004 13:29:44 :
I know this should be simple...but for some reason my brain isn't working.

I want my users to enter a the date in three seperate boxes. After the
users enters in two digits for the month I want the cursor to move to the
day textbox and so on....


Tiresome for the user.

Better to have a single box, in which YYYYMMDD can be entered
with/without field separators. Consider a validation function built on
:-

S = "12340608"

X = S.match(/^(\d\d\d\d)(\D?)(\d\d)(\2)(\d\d)$/)
if (!X) { alert("!") ; /* return false */ }
Y = +X[1] ; M = +X[3] ; D = +X[5]
with (Z = new Date(Y, M-1, D))
OK = getMonth()+1 == M && getDate() == D
// return OK

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gord | last post by:
Hello, VB6 accepts Date and Time values as 'Date'. I'm trying to verify entry into a database I'm creating by verifying that an appropriate Date or Time value has been entered. Using built-in...
6
by: christopher.secord | last post by:
I have a table containing typed log entries. One log entry is supposed to be created every twelve hours, but sometimes there are gaps. I need to create a report showing the time of entry, and the...
3
by: Don Sealer | last post by:
I'm guessing this is pretty simple however not simple enough for me. I'm developing a database to track expenses, income, banking transactions, etc. I have a very simple query with four fields,...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
7
by: Scott Frankel | last post by:
Still too new to SQL to have run across this yet ... How does one return the latest row from a table, given multiple entries of varying data? i.e.: given a table that looks like this: color...
2
by: x | last post by:
hi i am a pilot by profession. i want to create a database of my logbook using ms access 2002. i am facing a problem regarding the format of time field. when i select "Data/Time" data type for my...
10
by: Mike9900 | last post by:
Hello, I would like to store application expiration date in a file and store that file in a secure place, so the application can access the file for all the users on that computer. ...
2
by: Shawn Northrop | last post by:
So i created an XML file with php. here is the result: <mbInfo> <post date="2007-10-13"> <name>1</name> <email>11</email> <location>111</location> ...
2
by: DThreadgill | last post by:
Not sure how to begin with this one. My table consists of: Branch# (number, double) EntryDate (datetime, mm/dd/yyyy hh:mm:ss am/pm) One branch can have many entry dates (i.e, Branch # 76...
2
by: =?Utf-8?B?Z2lkZHk=?= | last post by:
hi, !!Please help! I've been at this for a few hours now! I'm probably doing something silly. heres my xml document: <Log> <entry user="Gideon" date="11/6/2008" time="10:14 AM"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.