Solved

Allow user to type in a date in DateField

Posted on 2006-06-12
12
1,261 Views
Last Modified: 2008-02-01
How can I setup a DateField component to allow the user to type in a date, or use the date picker by clicking on the icon in the DateField component?  Basically, I want to change the behavior so that the user can type the date in the textfield as opposed to being forced to use the calendar.  Any ideas?  

The only example that I was able to find on Google was for Flex.  Can anyone translate this Flex implementation to ActionScript 2.0?

http://jeff.mxdj.com/extended_datefield.htm
0
Comment
Question by:toggleHighQuality
  • 8
  • 4
12 Comments
 
LVL 7

Expert Comment

by:Ramy_atef
ID: 16889158
Hi,
I've made u an example, hope it would solve ur problem :)

u can download it from

http://www.yousendit.com/transfer.php?action=download&ufid=38039DCD4A17238B

Best Regards,
Ramy
0
 
LVL 7

Expert Comment

by:Ramy_atef
ID: 16889188
The idea is that i made a seperate text box and dateChooser (not date field) and a small button (a movie clip acutally)

you can type the date in the text box in the normal way, aslo you can click on the button to shoe the dateChooser , when u choose a date it'll write it to the text box and hide itself
also i made the DateChooser to disappear when u click on the button agian or if you clicked on the text box

download the file and check it ..

Ramy
0
 
LVL 1

Author Comment

by:toggleHighQuality
ID: 16889490
I figured something like this would be the work-around.  Thanks for putting this together, it really helps.  Hey, how can I make the date be formatted like DD/MM/YYYY?
0
 
LVL 1

Author Comment

by:toggleHighQuality
ID: 16889505
Also, I'm noticing that when I type in a date, and then press the date button, the calendar pops up, and disappears. :/
0
 
LVL 7

Expert Comment

by:Ramy_atef
ID: 16889547
for the disappear thing , put this code on the button

onClipEvent (load) {
      flag = false;
}
on (release) {
      if (flag) {
            _root.dc._visible = false;
            flag = false;
      } else {
            _root.dc._visible = true;
            flag = true;
      }
      _root.dc.setFocus();
}
0
 
LVL 7

Expert Comment

by:Ramy_atef
ID: 16889552
I've just changed this line

_root.dc.setFocus();

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 7

Expert Comment

by:Ramy_atef
ID: 16889607
For the DD/MM/YYYY put this text on the dataChooser

onClipEvent (load) {
      this._visible = false;
      function addZero(num) {
            if (num<10) {
                  num = "0"+num;
            }
            return (num);
      }
}
on (change) {
      myDate = this.selectedDate;
      myDay = addZero(myDate.getDate());
      myMonth = addZero(myDate.getMonth()+1);
      myYear = myDate.getFullYear();
      _root.textBox.text = myDay+"/"+myMonth+"/"+myYear;
      this._visible = false;
      _root.myButton.flag = false;
}

Best Regards,
Ramy
0
 
LVL 1

Author Comment

by:toggleHighQuality
ID: 16905545
This is great stuff.  So, if I change the date in the field, and then press the button, the calendar doesn't reflect the date that I put in the textfield.  Got anything for that?
0
 
LVL 7

Expert Comment

by:Ramy_atef
ID: 16905770
Hi
this would be very much coding (a nightmare actually) as you don't know what is the format that the user will write the date with
DD/MM/YY , MM/DD/YY , DD/MM/YYYY, MM/DD/YYYYY, MM-DD-YY ,... etc

if you wanted the text box to be cleared when the user click on the button you can write this on the button
textBox = ""

Best Regards,
Ramy
0
 
LVL 1

Author Comment

by:toggleHighQuality
ID: 16906010
Would Assuming that they entered the same format as what the calendar gives back make it easier?
0
 
LVL 7

Expert Comment

by:Ramy_atef
ID: 16906051
sure..
I'll make it to you assuming that the user will enter it the same way as the calendar
0
 
LVL 7

Accepted Solution

by:
Ramy_atef earned 500 total points
ID: 16906763
I've made it to u
you can download it from:

www.pylon-group.com/temp/date.zip

PS. I've restricted the input to numbers and "/" only to limit user errors

Regards,
Ramy
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now