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

Home Posts Topics Members FAQ

Auto insert Date in form input field

I just want to enter today's date in a text input box with the format
mm/dd/yyyy when it receives focus. I've been playing around with this but
just can't seem to get it to work.

Any help would be appreciated.

Doug
Jul 20 '05 #1
9 23677
Lee
Dwalker said:

I just want to enter today's date in a text input box with the format
mm/dd/yyyy when it receives focus. I've been playing around with this but
just can't seem to get it to work.


<html>
<head>
<script type="text/javascript">
function zp(n){
return n<10?("0"+n):n ;
}
function insertDate(t,fo rmat){
var now=new Date();
var DD=zp(now.getDa te());
var MM=zp(now.getMo nth()+1);
var YYYY=now.getFul lYear();
var YY=zp(now.getFu llYear()%100);
format=format.r eplace(/DD/,DD);
format=format.r eplace(/MM/,MM);
format=format.r eplace(/YYYY/,YYYY);
format=format.r eplace(/YY/,YY);
t.value=format;
}
</script>
</head>
<body>
<form>
<input onfocus="insert Date(this,'MM/DD/YYYY')"><br>
<input onfocus="insert Date(this,'MM/DD/YY')"><br>
<input onfocus="insert Date(this,'DD/MM')"><br>
<input onfocus="insert Date(this,'YYYY-MM-DD')"><br>
</form>
</body>
</html>

Jul 20 '05 #2

"Lee" <RE************ **@cox.net> wrote in message
news:bk******** @drn.newsguy.co m...
Dwalker said:

I just want to enter today's date in a text input box with the format
mm/dd/yyyy when it receives focus. I've been playing around with this but
just can't seem to get it to work.


<html>
<head>
<script type="text/javascript">
function zp(n){
return n<10?("0"+n):n ;
}
function insertDate(t,fo rmat){
var now=new Date();
var DD=zp(now.getDa te());
var MM=zp(now.getMo nth()+1);
var YYYY=now.getFul lYear();
var YY=zp(now.getFu llYear()%100);
format=format.r eplace(/DD/,DD);
format=format.r eplace(/MM/,MM);
format=format.r eplace(/YYYY/,YYYY);
format=format.r eplace(/YY/,YY);
t.value=format;
}
</script>
</head>
<body>
<form>
<input onfocus="insert Date(this,'MM/DD/YYYY')"><br>
<input onfocus="insert Date(this,'MM/DD/YY')"><br>
<input onfocus="insert Date(this,'DD/MM')"><br>
<input onfocus="insert Date(this,'YYYY-MM-DD')"><br>
</form>
</body>
</html>

Jul 20 '05 #3
JRS: In article <wR************ ******@bignews3 .bellsouth.net> , seen in
news:comp.lang. javascript, Dwalker <dl*******@hotm ail.com> posted at
Thu, 25 Sep 2003 13:47:05 :-
I just want to enter today's date in a text input box with the format
mm/dd/yyyy when it receives focus. I've been playing around with this but
just can't seem to get it to work.


That format should nor be used on the World-Wide Web; since only a few
countries use it, it is generally misleading (as is dd/mm/yyyy, of
course).

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 20 '05 #4
Ivo

"Dr John Stockton" <sp**@merlyn.de mon.co.uk> wrote in message
news:ro******** ******@merlyn.d emon.co.uk...
JRS: In article <wR************ ******@bignews3 .bellsouth.net> , seen in
news:comp.lang. javascript, Dwalker <dl*******@hotm ail.com> posted at
Thu, 25 Sep 2003 13:47:05 :-
I just want to enter today's date in a text input box with the format
mm/dd/yyyy when it receives focus. I've been playing around with this but
just can't seem to get it to work.


That format should nor be used on the World-Wide Web; since only a few
countries use it, it is generally misleading (as is dd/mm/yyyy, of
course).


Things became confusing only after the colonists in the New World went
looking for an identity in spelling anomalies.
No 'countries' that I know of use the format yyyy/mm/dd although that is the
one which sorts alphabetically and chronologically simultaneously. Or would
you suggest using the Julian Day Number?
Ivo
Jul 20 '05 #5
Lee
Dr John Stockton said:

JRS: In article <wR************ ******@bignews3 .bellsouth.net> , seen in
news:comp.lang .javascript, Dwalker <dl*******@hotm ail.com> posted at
Thu, 25 Sep 2003 13:47:05 :-
I just want to enter today's date in a text input box with the format
mm/dd/yyyy when it receives focus. I've been playing around with this but
just can't seem to get it to work.


That format should nor be used on the World-Wide Web; since only a few
countries use it, it is generally misleading (as is dd/mm/yyyy, of
course).


Curiosity: How widely accepted is yyyy-mm-dd out there in the Rest of
The World? In addition to software development, I've been using it on
bank drafts and forms for several months, but have never spotted it in
the wild (USA-AZ).

Jul 20 '05 #6
JRS: In article <bl*********@dr n.newsguy.com>, seen in
news:comp.lang. javascript, Lee <RE************ **@cox.net> posted at Fri,
26 Sep 2003 10:26:22 :-
Dr John Stockton said:

JRS: In article <wR************ ******@bignews3 .bellsouth.net> , seen in
news:comp.lan g.javascript, Dwalker <dl*******@hotm ail.com> posted at
Thu, 25 Sep 2003 13:47:05 :-
I just want to enter today's date in a text input box with the format
mm/dd/yyyy when it receives focus. I've been playing around with this but
just can't seem to get it to work.


That format should nor be used on the World-Wide Web; since only a few
countries use it, it is generally misleading (as is dd/mm/yyyy, of
course).


Curiosity: How widely accepted is yyyy-mm-dd out there in the Rest of
The World? In addition to software development, I've been using it on
bank drafts and forms for several months, but have never spotted it in
the wild (USA-AZ).


It is, I have been lead to understand, a US Federal Standard.
USA Standard: ANSI X3.30-1985(R1991), FIPS PUB 4-1, 4-2.
if you indulge in foreign travel, it is also
Canada: CAN/CSA-Z234.5-89. (Z234-4 ?)
and many others.
It matters not, however, how widely it is used, but how widely it is
understood correctly.

My Bank have remarked (audibly) on seeing it, but have understood it and
accepted it without demur.

A date in MM/DD/YYYY, such as Jan 4th, being written as 01/04/2004, will
be understood throughout Europe as meaning April Fools Day. The date of
Remembrance Sunday, written demotically in the UK as 09/11/2003, will be
misunderstood by Americans.

But everyone can understand 2004/04/11 as being the coming Easter
Sunday, given an adequate 2004 diary.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 20 '05 #7
JRS: In article <3f************ *********@news. wanadoo.nl>, seen in
news:comp.lang. javascript, Ivo <no@thank.you > posted at Fri, 26 Sep 2003
19:43:42 :-

"Dr John Stockton" <sp**@merlyn.de mon.co.uk> wrote in message
news:ro******* *******@merlyn. demon.co.uk...
JRS: In article <wR************ ******@bignews3 .bellsouth.net> , seen in
news:comp.lang. javascript, Dwalker <dl*******@hotm ail.com> posted at
Thu, 25 Sep 2003 13:47:05 :-
>I just want to enter today's date in a text input box with the format
>mm/dd/yyyy when it receives focus.
That format should nor be used on the World-Wide Web; since only a few
countries use it, it is generally misleading (as is dd/mm/yyyy, of
course).


Things became confusing only after the colonists in the New World went
looking for an identity in spelling anomalies.


Any responsibility that the UK may have for this must be shared in part
with the country that founded New Amsterdam. It is one thing, I
suspect, for which the French need not be blamed.
No 'countries' that I know of use the format yyyy/mm/dd although that is the
one which sorts alphabetically and chronologically simultaneously.
I believe Japan and China use it routinely. MSDOS 5 believes that YYYY-
MM-DD is also used in French Canada, Hungary, Czechoslovakia, Sweden,
Yugoslavia, Poland.
Or would
you suggest using the Julian Day Number?


No, not least because the Julian Day Number does not define a Civil
Date. Modified JD defines a UK Civil Date (ignoring Summer Time); and
Chronological JD & CMJD define a civil date anywhere.

For more, see via below.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 20 '05 #8
Dr John Stockton wrote on 28 sep 2003 in comp.lang.javas cript:
But everyone can understand 2004/04/11 as being the coming Easter
Sunday, given an adequate 2004 diary.


In 2004 everywhere, but:

"The Orthodox Easter usually falls later than the Catholic Easter,
depending on when Passover is. The Russian Easter falls one week after
Passover."

Year 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010

Catholic 23/4 15/4 31/3 20/4 11/4 27/3 16/4 8/4 23/3 12/4 4/4
Orthodox 30/4 15/4 5/5 27/4 11/4 1/5 23/4 8/4 27/4 19/4 4/4
John, as a numbercruncher you will like this, I hope:

<http://www.assa.org.au/edm.html>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #9
JRS: In article <Xn************ ********@194.10 9.133.29>, seen in
news:comp.lang. javascript, Evertjan. <ex************ **@interxnl.net >
posted at Sun, 28 Sep 2003 21:01:17 :-
Dr John Stockton wrote on 28 sep 2003 in comp.lang.javas cript:
But everyone can understand 2004/04/11 as being the coming Easter
Sunday, given an adequate 2004 diary.
In 2004 everywhere, but:

"The Orthodox Easter usually falls later than the Catholic Easter,
depending on when Passover is. The Russian Easter falls one week after
Passover."

Year 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010

Catholic 23/4 15/4 31/3 20/4 11/4 27/3 16/4 8/4 23/3 12/4 4/4
Orthodox 30/4 15/4 5/5 27/4 11/4 1/5 23/4 8/4 27/4 19/4 4/4


Not only "Catholic", but also "Protestant "; or, to give due credit,
"Gregorian" . The first row agrees with Zeller & other sources.

But, while I have reliable algorithms for Julian Easter, I have nothing
that gives the Orthodox row of dates. Is that Passover the Pesach of
the accepted Hebrew calendar, or is it some rival computation?

Hebrew Pesach is 15 Nisan, and the Hebrew Year rotates slowly against
the Gregorian; so, if it is the same Pesach, the attached Easter will
not remain with Gregorian April/May. OTOH, neither will remain forever
in accord with the actual seasons.
John, as a numbercruncher you will like this, I hope:
<http://www.assa.org.au/edm.html>

Will look.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 20 '05 #10

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

Similar topics

2
12717
by: Tom | last post by:
I am trying to store information into a table that has an auto increment field. There is currently no data in the table. Using the code below I cannot insert data into the table. I get an error telling me that "Number of query values and destination fields are not the same." If I add a value for the auto increment field to the SQL String the data is entered into the table with no problems but obviously the auto increment field now...
4
10649
by: the hotshot | last post by:
hello, this seems to be a hard question so far and noone has been able to help with this. is it possible to have access start an autonumber with a prefix according to the year when the data is entered. for example, if i entered something in 2004, i would like the number to bigin with 2004003, 2004004, 2004005... and same for 2005001, 2005002...? much and great appreciation for suggestions. thank you,
5
17713
by: Navillus | last post by:
Hey gang, I have a login form that is empty by default, but can be filled with values from a previous form: <input type=text maxlength="40" size="40" name="user" value="`usr`"> <input type=password maxlength="8" name="password" value="`pss`"> where usr and pss are sent from the previous form.
6
2746
by: AA Arens | last post by:
Hi, I have a database with 2 main forms. Contacts and companies. I share the base with two others via LAN. On the companies form I have buttons to navigate throught the records (>400). We are mostly handling let say 5 companies. Every time I have to navigate or choose the find record button to get the right company. I am looking fo a feature to have listed in a combo list the last 5 visited records ("recently visited records").
0
4456
chumlyumly
by: chumlyumly | last post by:
Hello scripters - OS: Mac OSX Language: PHP w/ MySQL database I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The tables are all linked with the field 'member_id', which is an auto-increment field in the parent table ('members'). I've been able to input multiple records into the other three tables 'specialty_groups', 'committee_interest' and 'committee_member'...
6
12437
by: awojciehowski | last post by:
I am working with a database now and need some guidance. I am attempting to input an auto calculation. I have the ability to enter a date in a text box on a form. I want to be able to have another field that auto calcuates 90 days later and simiply displays that date. The auto calculated date does NOT have to be assiocated with a field in any table, just a caculation in what I believe would be referred to an unbounded box. For example,...
6
12238
by: ndeeley | last post by:
Hi, How do I insert a null or blank field into a database using coldfusion? I'm new to CF and its proviing a bit tricky! My database date field accepts null values (I think - theres no default value or validation rule). The input box on the form is this: <input type="text" name="QuotePDate" maxlength="10" size="12" /> and is handled by the action form as this:
58
8126
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also the parts section an i seem to be having trouble. When i try to insert into the parts section i get the error Invalid character value for cast specification. But not sure what i am doing wrong. Here is what i am using to insert. All the sections...
0
3354
by: brianrpsgt1 | last post by:
I am attempting to insert data from a HTML form using a .psp script. I can not find how to link the data that is inserted into the form to the variables in the .psp script to then insert into the MySQL Insert statement. I am familiar with PHP, where you would write $_POST(), however I can not find the equivalent in PSP. I believe that this is the my missing piece. Technically, what is occurring that that when I click the 'Submit'...
0
9595
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
9432
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
10059
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
10008
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
9873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7420
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
6682
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();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.