Dear scripters,
I am working on a HTML form in which a date must be entered of the form
'dd-mm-yyyy'. Now I'm looking for a script that, when the user switches to
another form field, changes e.g. 'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'.
I have searched the net using google, but only found validators that show
an error if an incorrect format is used. (and I can't write one on my own)
Does someone has such a script for me?
much thanks in advance!
Martin 36 11309
Martin Herrman said: Dear scripters,
I am working on a HTML form in which a date must be entered of the form 'dd-mm-yyyy'. Now I'm looking for a script that, when the user switches to another form field, changes e.g. 'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'.
I have searched the net using google, but only found validators that show an error if an incorrect format is used. (and I can't write one on my own)
That can't be done, because the code can't guess whether 1122005 is January 12
or November 2. That's why you have to ask the user to correct it.
"Lee" <RE************ **@cox.net> wrote in message
news:d1******** *@drn.newsguy.c om... Martin Herrman said: Dear scripters,
I am working on a HTML form in which a date must be entered of the form 'dd-mm-yyyy'. Now I'm looking for a script that, when the user switches
toanother form field, changes e.g. 'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'.
I have searched the net using google, but only found validators that show an error if an incorrect format is used. (and I can't write one on my
own) That can't be done, because the code can't guess whether 1122005 is
January 12 or November 2. That's why you have to ask the user to correct it.
Unless you only reformat the entry with dashes if it has a length of 8.
<html>
<head>
<title>ddmmyyyy .htm</title>
<script type="text/javascript">
function format(that) {
var what = that.value;
if (what.length != 8) return;
that.value = what.substr(0,2 ) + "-" + what.substr(2,2 ) + "-" +
what.substr(4);
}
</script>
</head>
<body>
<form>
<input type="text" name="dmy" size="10" maxlength="10"
value="01122005 " onblur="format( this)">
</form>
</body>
</html>
Lee wrote on 15 mrt 2005 in comp.lang.javas cript: Martin Herrman said: Dear scripters,
I am working on a HTML form in which a date must be entered of the form 'dd-mm-yyyy'. Now I'm looking for a script that, when the user switches to another form field, changes e.g. 'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'.
I have searched the net using google, but only found validators that show an error if an incorrect format is used. (and I can't write one on my own)
That can't be done, because the code can't guess whether 1122005 is January 12 or November 2. That's why you have to ask the user to correct it.
'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'.
Given these constraints and
the boundaries of the "current" century
it can be done.
function organize(x){
if (/^\d{8}$/.test(x))
x.value = x.replace(/(\d{2})(\d{2})( \d{4})/,'$1-$2-$3')
else if (/^\d{1,2}\d{1,2} \d{2}$/.test(x)) {
a = x.split('-')
x.value = two(a[0])+'-'+two(a[1])+
'-'+(+a[2]>30)?'19'+a[2]:'20'+a[2]
}
}
function two(x){
return (x<10)?'0'+x:x
}
...............
<input onblur='organiz e(this)'>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Evertjan. wrote on 15 mrt 2005 in comp.lang.javas cript: 'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'.
Given these constraints and the boundaries of the "current" century it can be done.
function organize(x){ if (/^\d{8}$/.test(x)) x.value = x.replace(/(\d{2})(\d{2})( \d{4})/,'$1-$2-$3') else if (/^\d{1,2}\d{1,2} \d{2}$/.test(x)) {
else if (/^\d{1,2}-\d{1,2}-\d{2}$/.test(x)) {
a = x.split('-') x.value = two(a[0])+'-'+two(a[1])+ '-'+(+a[2]>30)?'19'+a[2]:'20'+a[2] } }
function two(x){ return (x<10)?'0'+x:x }
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
In article <Xn************ ********@194.10 9.133.29>, ex************* *@interxnl.net says... Lee wrote on 15 mrt 2005 in comp.lang.javas cript:
Martin Herrman said: Dear scripters,
I am working on a HTML form in which a date must be entered of the form 'dd-mm-yyyy'. Now I'm looking for a script that, when the user switches to another form field, changes e.g. 'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'.
Instead of using a textbox, maybe you could try dynamic listboxes
instead. That way, when the month listbox is clicked, the appropriate
amount of days are filled in the days listbox.
This way, you wouldn't have to worry if they put in a bad character or
not.
Evertjan. said: Lee wrote on 15 mrt 2005 in comp.lang.javas cript:
Martin Herrman said: Dear scripters,
I am working on a HTML form in which a date must be entered of the form 'dd-mm-yyyy'. Now I'm looking for a script that, when the user switches to another form field, changes e.g. 'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'.
I have searched the net using google, but only found validators that show an error if an incorrect format is used. (and I can't write one on my own)
That can't be done, because the code can't guess whether 1122005 is January 12 or November 2. That's why you have to ask the user to correct it.
'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'.
Given these constraints and the boundaries of the "current" century it can be done.
But you can't assume those constraints.
"Lee" <RE************ **@cox.net> wrote in message
news:d1******** *@drn.newsguy.c om... Martin Herrman said: Dear scripters,
I am working on a HTML form in which a date must be entered of the form 'dd-mm-yyyy'. Now I'm looking for a script that, when the user switches
toanother form field, changes e.g. 'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'.
I have searched the net using google, but only found validators that show an error if an incorrect format is used. (and I can't write one on my
own) That can't be done, because the code can't guess whether 1122005 is
January 12 or November 2. That's why you have to ask the user to correct it.
"... e.g. 'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'." doesn't include
'd-mm-yyy';
therefore, '1122005' is November 2, 2005.
Unless the examples ("e.g.") were not definitive.
Lee wrote on 15 mrt 2005 in comp.lang.javas cript: 'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'.
Given these constraints and the boundaries of the "current" century it can be done.
But you can't assume those constraints.
They are given by the OP.
Why improving on a reasonable request,
instead of showing the asked code?
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
McKirahan wrote:
[...] "... e.g. 'ddmmyyyy' or 'dd-m-yy' to 'dd-mm-yyyy'." doesn't include 'd-mm-yyy'; therefore, '1122005' is November 2, 2005.
Based on the suggested format, I make it 1 December 2005, or it
may be 11 February 2005.
Or does ddmmyyyy really mean mmddyyyy?
--
Zif This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kevin Lyons |
last post by:
Hello,
I am trying to get all of my form elements passed correctly from the
following URL:
http://www.dslextreme.com/users/kevinlyons/selectBoxes.html
to the following URL:
http://www.dslextreme.com/users/kevinlyons/selectResults.html
I am passing name, email, countries, cities, products, courses, etc.
The others display as they should on the subsequent page,
|
by: williamc |
last post by:
Somebody asked me if it would be possible to add auto-advance to a web
form where there are a lot of repetitive 5 character fields. I took a
look around the web and found a script, which appears to work in the
couple of browsers I tried it in. However, when I look at the script it
appears to have the wrong number of brackets. Then when I changed the
script to the way I thought it should be, it still worked!
I'm totally rusty on...
|
by: mitch-co2 |
last post by:
What I am trying to do is when someone clicks on the YES radio button I
want the text field called MYTEXT to equal the text field named DATE.
The below code works as long as I do NOT UN-COMMENT the NO radio
button, once I do that it will not work.
Any help would be greatly appreciated.
Mitch
|
by: Nathan |
last post by:
I have an aspx page with a data grid, some textboxes, and an update button.
This page also has one html input element with type=file (not inside the data
grid and runat=server).
The update button will verify the information that has been entered and
updates the data base if the data is correct. Update will throw an exception
if the data is not validate based on some given rules. I also have a custom
error handling page to show the...
|
by: rgdwar1 |
last post by:
Hello, I have two issues I need help with:
I have a Data Entry form called Frm_Entry (with a corresponding table) with the following fields:
Date Assigned (Date)
Date Processed (Date)
Date Submitted (Date)
MS-Company (Text)
Client (Text)
Reimbursement Amount
| |
by: eunever32 |
last post by:
Hi
I have a struts (1.1) form
<html:form
<html:text
<html:text ...
|
by: jcage |
last post by:
Is there any tutorials online for sending email through forms? I can
send an email as well as write to my MySQL database from home with the
following code but not at work. I think there might be something I'm
missing header-wise that keeps me from making this work on my work
system. I'm using Apache 1.3, PHP 4.1 (best the IT guys could do
though I'm using 5.x at home), and MySQL as the database. Thanks VERY
much for any help or...
|
by: rlamber |
last post by:
Hello,
I have 2 subforms in a Main form, one links fine, the other doesn't. I am trying to link them both to a "tracking ID" on the main form. The Tracking ID is a text field that is a combination of an auto-number and an Alpha expression. The subform that links fine is a comments form (continuous form with just date field and memo box) and the subform that won't link is a larger, more detailed form where I would like to add more than one...
|
by: bleachie |
last post by:
Hey,
I just need some help, my form seems to not send me all of the 'guestNames' and 'guestEmails' forms.
i use this function to add more guestnames and guestemail fields based on the number of guests added.
form.php
function createGuestNameAndEmailElements()
{
|
by: MNNovice |
last post by:
I am working on a database on my CD collection using Access 2003. Some of the table structures are given below.
Table 1 tblMusicCategory
Field 1: MusicCategoryID - Auto Number (PK)
Field 2: MusicCategory - text
Field 3: MusicCategoryAbbv - text
Table 2 tblArtists
Field 1 ArtistID - Auto Number (PK)
|
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...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |