Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Form Date Validation Script

New Here ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

I have a Suspense Date Block on my Form and I want an Error to pop up not allowing users to enter a date that is within 10 days of the current date and time.  I need a JAVA Script to make this happen, I am not versed in Java Script to make this happen and am looking for help from the community.  BLUF: If todays Date is 05/24/2021 9:41am and you try to put in a Suspense daye earilier than 06/03/2021 9:41am than the system will give you an error saying "As per SOP your Request must be Approved by the CoS".

 

Thank you for your help. 

TOPICS
Create PDFs, JavaScript, PDF forms

Views

279

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

You can do it using this code as the field's custom validation script:

 

if (event.value) {
	var d = util.scand("m/d/yy HH:MM", event.value);
	var now = new Date();
	var tenDays = 864000000;
	if ((d.getTime()-now.getTime())<tenDays) {
		app.alert("As per SOP your Request must be Approved by the CoS");
		event.rc = false;
	}
}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

That worked Perfectly, For my reference what is the 864000000 refence for? is that JS Math for 10 days? 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

LATEST

It's the number of milliseconds in 10 days.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines