How to check the date in this format dd/mm/yyyy is not less than current date and show app allert if the date is less than current?

Community Beginner ,
Jul 10, 2018

Copy link to clipboard

Copied

Hello,

how to check the date in this format dd/mm/yyyy  in one field in adobe form is not less than current date and show app allert if the date is less than current?

I read this:
How to compare dates in Java? - Stack Overflow

But how can I use it in adobe pdf forms to check the start date is equal to  today date, if  it is less than today date then show me appalert message.

I tried this:

today.date = new Date();

var sStart = getField("fill_9").valueAsString;

dStart = util.scand("dd/mm/yyyy", sStart);

if ( new Date() < dStart) 

{

app.alert ( " alert"); 

but it doesn't work.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

189

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

How to check the date in this format dd/mm/yyyy is not less than current date and show app allert if the date is less than current?

Community Beginner ,
Jul 10, 2018

Copy link to clipboard

Copied

Hello,

how to check the date in this format dd/mm/yyyy  in one field in adobe form is not less than current date and show app allert if the date is less than current?

I read this:
How to compare dates in Java? - Stack Overflow

But how can I use it in adobe pdf forms to check the start date is equal to  today date, if  it is less than today date then show me appalert message.

I tried this:

today.date = new Date();

var sStart = getField("fill_9").valueAsString;

dStart = util.scand("dd/mm/yyyy", sStart);

if ( new Date() < dStart) 

{

app.alert ( " alert"); 

but it doesn't work.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

190

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
Jul 10, 2018 0
Most Valuable Participant ,
Jul 10, 2018

Copy link to clipboard

Copied

Use this code as the field's custom validation script:

if (event.value!="") {
    var d = util.scand("dd/mm/yyyy", event.value);

    if (d.getTime()<new Date().getTime()) app.alert("You can't enter a date prior to today!");
}

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
Reply
Loading...
Jul 10, 2018 1
Community Beginner ,
Jul 10, 2018

Copy link to clipboard

Copied

Thank you!

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
Reply
Loading...
Jul 10, 2018 0
Community Beginner ,
Jul 10, 2018

Copy link to clipboard

Copied

But I want app alert only for less than  today date, and I don't want app alert when I put today date.

?

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
Reply
Loading...
Jul 10, 2018 0
Most Valuable Participant ,
Jul 10, 2018

Copy link to clipboard

Copied

Use this, then:

if (event.value!="") {

    var d = util.scand("dd/mm/yyyy", event.value);

    d.setHours(23);

    d.setMinutes(59);

    d.setSeconds(59);

    if (d.getTime()<new Date().getTime()) app.alert("You can't enter a date prior to today!");

}

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
Reply
Loading...
Jul 10, 2018 1
Community Beginner ,
Jul 10, 2018

Copy link to clipboard

Copied

Yes, thank you!!!

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
Reply
Loading...
Jul 10, 2018 0