• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

1.2K

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
Community Expert ,
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;
	}
}

Votes

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? 

Votes

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
Community Expert ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

LATEST

It's the number of milliseconds in 10 days.

Votes

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