Weird re-format for dates

message from Zwi2000 on 18 Jul 2004
I know this might be too much, but you know how clients are ... they are
asking that while typing a date in a field.
Which is 10 digit long (mm/dd/yyyy). That once they enter the first two
digits the "/" is displayed automatically, then type the next two digits and
the other "/" is entered automatically, finally user enters the last 4
digits.

This would allow them to enter the numbers only, is this possible ?

Z
 
Mick White replied to Zwi2000 on 19 Jul 2004
http://www.mickweb.com/demo/dateInput.html

Yes it can be done:
onkeyup='if(this.value.length==2 || this.value.length==5)this.value+="/"'
But I wouldn't call it reliable, though.

I would check the "entry":

onchange='if(!(/^\d{2}\/\d{2}\/\d{4}$/.test(this.value))){
this.value=window.prompt("Please enter in the format mm/dd/yyyy","")}'

That's a very crude test though.
You could at least check to see if it's a valid date(between earliest
and latest acceptable dates), if you want to pursue this, I'll show you
how to do it.
Mick

Zwi2000 wrote:
 

Archived message: Weird re-format for dates (Macromedia Dreamweaver)