473,776 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="frmdatebo xes" action="test2.a sp" method="post">
<input type="hidden" name="hidBBdate " value="">
<input type="text" name="txtmonth" class="smalltxt box" maxlength="2"
onKeyPress="che cklen(this,2);" > /
<input type="text" name="txtday" class="smalltxt box" maxlength="2"
onKeyPress="che cklen(this,2);" > /
<input type="text" name="txtyear" class="txtbox" maxlength="4"
onKeyPress="che cklen(this,4);" >
</form>

function checklen(tFormO bj, tLen)
{
if (tFormObj.value .length == tLen)
{
document.forms["frmdatebox es"].nextelement.fo cus();
}
}
TIA
-Bruce Duncan
Jul 23 '05 #1
7 1437

"Bruce Duncan" <bruce~w~duncan @~hotmail.com> wrote in message
news:10******** *****@corp.supe rnews.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="frmdatebo xes" action="test2.a sp" method="post">
<input type="hidden" name="hidBBdate " value="">
<input type="text" name="txtmonth" class="smalltxt box" maxlength="2"
onKeyPress="che cklen(this,2);" > /
<input type="text" name="txtday" class="smalltxt box" maxlength="2"
onKeyPress="che cklen(this,2);" > /
<input type="text" name="txtyear" class="txtbox" maxlength="4"
onKeyPress="che cklen(this,4);" >
</form>

function checklen(tFormO bj, tLen)
{
if (tFormObj.value .length == tLen)
{
document.forms["frmdatebox es"].nextelement.fo cus();
}
}
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.supernew s.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.nextelemen t 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(tFormO bj, tLen)
{
alert(tFormObj. value);
if (tFormObj.value .length == tLen)
{
document.forms["frmdatebox es"].nextelement.fo cus();
}
}
</script>
</head>

<body>
<form name="frmdatebo xes" action="test2.a sp" method="post">
<input type="hidden" name="hidBBdate " value="">
<input type="text" name="txtmonth" class="smalltxt box" maxlength="2"
onKeyUp="checkl en(this,2);"> /
<input type="text" name="txtday" class="smalltxt box" maxlength="2"
onKeyUp="checkl en(this,2);"> /
<input type="text" name="txtyear" class="txtbox" maxlength="4"
onKeyUp="checkl en(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.supe rnews.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="frmdatebo xes" action="test2.a sp" method="post">
<input type="hidden" name="hidBBdate " value="">
<input type="text" name="txtmonth" class="smalltxt box" maxlength="2"
onKeyPress="che cklen(this,2);" > /
<input type="text" name="txtday" class="smalltxt box" maxlength="2"
onKeyPress="che cklen(this,2);" > /
<input type="text" name="txtyear" class="txtbox" maxlength="4"
onKeyPress="che cklen(this,4);" >
</form>

function checklen(tFormO bj, tLen)
{
if (tFormObj.value .length == tLen)
{
document.forms["frmdatebox es"].nextelement.fo cus();
}
}
TIA
-Bruce Duncan

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

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

<form name="frmdatebo xes" action="test2.a sp" method="post">
<input type="hidden" name="hidBBdate " value="">
<input type="text" name="txtmonth" class="smalltxt box" maxlength="2"
onKeyUp="checkl en(this,2,'txtd ay');"> /
<input type="text" name="txtday" class="smalltxt box" maxlength="2"
onKeyUp="checkl en(this,2,'txty ear');"> /
<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.c om...
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.supernew s.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.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.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
11000
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 VB functions/properties etc., I can't seem to unambiguously confirm that an entry is a valid date or valid time value? (I would like to try and do this without having to write some huge procedure that processes an entry character by character,...
6
1957
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 actual log entry. I can't just list the contents of the log table, because if I do that there will be dates missing. Instead, when there isn't a log entry for a date, I need to print the date, and then just leave the log entry blank. The SQL...
3
2881
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, date, checking account deposits, savings account deposits, savings account withdrawals. How do I get this query to only show dates when a transaction occurred in one of the other three fields? Thanks, Don..............
18
3043
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
6367
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 | date --------+------------ red | 2004-01-19 blue | 2004-05-24
2
2469
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 time field then this format gives the liberty to record times uptill a figure of 59 in different sub-formats, whereas i want the format to be able to record the times like 80:35 or 1:10 or 1138:00. which means that i have these many hours on a...
10
6818
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. IsolatedStorage is a good technique but it is for the each user only and is not machine level. Registry is not good because the user may not have access permission. Application directory is not good because the file could be deleted and so the...
2
1351
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> <message/> </post>
2
4185
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 has 10 entry dates). I'm trying to show the most recent entry date & the previous entry date on a report. I know how to get the most recent entry date using Max. How would I get to the previous entry date? (Current is 2/14/2008 2:26:07 PM and...
2
6304
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" action="Searched" /> <entry user="Jennie" date="11/6/2008" time="10:14 AM" action="Finished her
0
9628
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9464
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10292
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10061
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8954
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4031
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.