Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

date range validation

Avatar

Level 1

Hi,

I hope someone can help me...I am new to form scripting. With my form I am able to define date range

that user submits but when user picks date outside range (3 days) the date is still allowed...how can I prevent any date

outside range or maybe just null date field until date is within range...any help would be appreciated.

----- form1.#subform[4].Table1.Row1.Name[0]::change: - (FormCalc, client) --------------------------

var todayNumber = date()

var endNumber = Date2Num(xfa.event.newText, "M/D/YY")

if ((todayNumber - endNumber) <= -3 ) then

    xfa.host.messageBox("You must choose a date within 3 days")

   

   

   

    endif

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can blank the field by placing the following statement inside the if condition..

$.rawValue = "";

I had placed the messagebox to find out what is the format of the date that is send when you choose the date from the control. You donot need this. So you can delete it.

$host.messageBox($.rawValue)

Thanks

Srini

View solution in original post

0 Replies

Avatar

Level 10

Try placing the code in the Exit event with FormCalc.

var todayNumber = date();

var endNumber = Date2Num(this.rawValue, "M/D/YY");

if ((todayNumber - endNumber) <= -3 ) then

    xfa.host.messageBox("You must choose a date within 3 days");

     //Empty the Date field.

    this.rawValue = "";

endif

Thanks

Srini

Avatar

Level 1

Thank you for your response, I tried in placing code in Exit event to no avail, any other suggestions would be appreciated....

Avatar

Level 10

If you can share the form,then it will be easy to find out where the issue is..

Steps to share a document..

1. Go to URL http://Acrobat.com
2. Create an account if you don't have one.
3. Then login to the website.
4. In top left corner you will see a button called Upload.
5. Click on browse and select the file you want to upload.
6. After Uploading, mouse over on the uploaded file. Click the down arrow button and choose Share document.
7. Then you will be prompted a popup window at the lower left corner. Choose "Publish it" option.
8. In the next pop up window choose "Copy Link" option.
9. You can paste the link in the forum thread.

Thanks

Srini

Avatar

Level 1

Thanks again...I am new to Livecycle so any insight would be appreciated, here is the form which still needs some work.

https://acrobat.com/#d=8VIaLdsTc7iEYWrIBzXk3g

Avatar

Level 10

Here is the corrected form.

I placed the code in the exit event of the field.

Compate the code you had previously with the one I put.

https://acrobat.com/#d=gXOscpKAL6nhuzzFFi0FLg

Thanks

Srini

Avatar

Level 1

Hi,

The DATE field is still allowed to be submitted outside the date range, the message pops "You must choose....)

then the bad date is put in field, can this be reset to blank until right date range is entered?

Also why have this message....$host.messageBox($.rawValue)

Thank you!

Avatar

Correct answer by
Level 10

You can blank the field by placing the following statement inside the if condition..

$.rawValue = "";

I had placed the messagebox to find out what is the format of the date that is send when you choose the date from the control. You donot need this. So you can delete it.

$host.messageBox($.rawValue)

Thanks

Srini