cancel
Showing results for 
Search instead for 
Did you mean: 

Need scripting for date field

0 Kudos

Hi all,

My requirement is that i have a date field with the calendar help.i have set the current date as default in that field. Now i have to display an error message if i select a date 6 months older than the current date.Can anyone please guide me on this. I need it urgently.

Points rewarded for helpful answers.

Regards,

Srividya.

Accepted Solutions (1)

Accepted Solutions (1)

vaibhav_tiwari
Contributor
0 Kudos

Hi Srividya,

Write the following FormCalc Script at the exit event of your Date Field:

Var val1 = substr((Num2Date(Date(), "DD/MM/YYYY")), 1, 2) - substr((Num2Date((IsoDate2Num($.rawValue)), "DD/MM/YYYY")), 1, 2);

Var val2 = substr((Num2Date(Date(), "DD/MM/YYYY")), 4, 2) - substr((Num2Date((IsoDate2Num($.rawValue)), "DD/MM/YYYY")), 4, 2);

Var val3 = substr((Num2Date(Date(), "DD/MM/YYYY")), 7, 4) - substr((Num2Date((IsoDate2Num($.rawValue)), "DD/MM/YYYY")), 7, 4);


if ( val3 > 0 )
then
	val2 = val2 + 12
endif

if ( val1 >= 0 and val2 == 6)
then
	$host.messageBox("Do not enter a date vold more than 6 months")
elseif (val2 > 6)
then
	$host.messageBox("Do not enter a date vold more than 6 months")
elseif (val3 > 1)
then
	$host.messageBox("Do not enter a date vold more than 6 months")
endif

here val1 is form counting date, val2 is for counting month and val3 is for years.

I have to spend a lot of energy to write it so hope it will solve your problem.

Regards,

Vaibhav Tiwari.

Edited by: Vaibhav Tiwari on Jun 27, 2008 4:43 PM

0 Kudos

Hi Vaibhav,

Thank you very much for the answer and sorry for the late reply.I have rewarded points for this answer.It solved my problem.

Regards,

Srividya.

0 Kudos

Hi Vaibhav,

I have added the code wat you have given to the date field.But when the error pops up in the output,it is displaying a small error screen inside a blank adobe screen which remains even after clickin ok on the error message.Can you please guide me on how to remove this blank adobe screen.

Regards,

Srividya.

Answers (0)