Date Validation

I have a UI component calendar that populates a text box that I validate before I let the form send.

All works fine in this department until you put the date in the text box manually, then the form does not think there is a valid date. This is because I validate the two dates not by what’s in the textbox, but by what date the person chose in the calendar UI component.

Confusing I know.

:hair:

So, how can I take a date someone puts is a listbox and formulate it so it looks like this
There date = 2/31/2003
Formulates to inputday = 1
inputmonth = 31
inputYear = 2003
I think if I have it in this form I can validate the date against the current date.

Or, where is a good web site with form/date validation?

Thanks

Bill

This is odd because it is the second post today I have seen with validation in ActionScript. I don’t understand why we are trying to validate at this level when perl and other server-side scripts have built in regular expressions to handle this anf I am not aware of any validation methods in actionscript. I could be wrong…Anybody seen otherwise?

I am outputting error messages in flash when the user chooses an incorrect date. If we do it on the server side, we will have to go to a new page to tell them the date is incorrect. :sigh:

O, and by the way rynoe your movie kicks a$$

well…

have you tried validating the textbox also?

No, that is the trouble I’m having, the validation does not come from what is in the textbox. It happens behind the scenes by what was selected in the calendar and the current date. How would you go about putting a date in a textbox and validating it?

Right now I am validating my selected calendar date like this

goodYear = (getTodayYear<=_root.calender_mc.getCYear);
if (goodYear) {
trace(“goodYear”);
}

goodMonth = (getTodayMonth <= _root.calender_mc.getCMonth);
if (goodMonth) {
trace(“goodMonth”);
}

This is not all the code, just letting you get the drift.

How can I break apart a date in a listbox?

1/2/2003 TO something like;

year = 2003
month = 2
day = 1

I am looking for some code I remember something like variable.indexOf or something like that to parse textboxes…

Thanks rynoe,

It took a while but I got everything to work. Basicly I did what you said, I parsed out the text box and validated the date.

I’m glad you got it, I’d like to know hoe you did it cause I never found what I was looking for…

I have know time right now to explain; give me a bit and I’ll let you know.

:cool:

I wanted to validate a date in a text box with the current date, so first I needed to parse out the date in the text box;

expirationDateK = _root.calender_mc.expirationDateN
d = new String(expirationDateK);
inputMonth = d.slice( 0, 2);
trace(inputMonth);

m = new String(expirationDateK);
inputDay = m.slice( 3, 5);
trace(inputDay);

y = new String(expirationDateK);
inputYear = y.slice( 6, 10);
trace(inputYear);

expirationDateN is the var name of my text box. One thing to watch out for is the date in the text box must look like this mm/dd/yyyy.

Then use if statements to verify the inputDate with the current date. For example;

switch()
case 1 :
goodYear = (inputYear.length && getTodayYear <= inputYear)
if (goodYear) {
trace(“goodYear”);

This if statements is inside of a switch function.
Hope this helps.
Peace OUT
:stuck_out_tongue: