cancel
Showing results for 
Search instead for 
Did you mean: 

How to get current date?

Former Member
0 Kudos

Hi,

I am using JAvascript in my ADOBE form and my requirement is to check the date of birth entered by the user.

The date should be < current date and the calculated age on current date should be >= 18 years.

Could anyone help me to achieve this.

Thanks,

Shilpa Bansal.

Accepted Solutions (1)

Accepted Solutions (1)

varun_vadnala3
Active Participant
0 Kudos

In adobe form in the context tab you have systems field(sfpsy-date).From that drag the date on to the context.In the layout of teh adobe form create a text field and bind this system date.

Now in javascript u can use this text field fo your validation.

Former Member
0 Kudos

Hi Varun,

Thanks. I further have 1 query. How do we compare date fields in adobe forms?

Do we use the normal operators like >= , <-= or there is another way?

I tried comparing 2 date format fields but it is not working as expected.

Thanks,

Shilpa Bansal.

Abhijit74
Active Contributor
0 Kudos

Hello,

Are you asking about java script in sap adobe form ? Then you are right the operators are >= or <= or != or == etc.

But where you are writing the script is also important. you need to write the script into correct event.

Thanks & Regards,

Abhijit

Former Member
0 Kudos

Hi Abhijit,

The comparison operators are not working as desired.

I have coded in EXIT event:

                                   if (this.rawValue >= employeeform.currdate.rawValue);

                                   xfa.host.messageBox("DOB cannot be greater than current date","Error",0);

But when i test it, it always gives the error message even if the date entered is < the value in employeeform.currdate.rawValue.

Any pointers?

Thanks,

Shilpa BAnsal.


Answers (3)

Answers (3)

0 Kudos

hi,

You can also use date = xfa.timeStamp;

Miguel

Former Member
0 Kudos

Hi,

Does anyone have any solution to this problem.

I am really stuck up in it.

Thanks,
Shilpa Bansal

0 Kudos

hi

var date = new Date();

var d = ((date.getDate().length)<1? date.getDate():"0"+date.getDate())

var m= (date.getMonth()+1).length<1? (date.getMonth()+1):"0"+(date.getMonth()+1);

var y = date.getFullYear();

var date1 = (d+"-"+m+"-"+y).toString();

Former Member
0 Kudos

Hi,

I found a set of Date and time functions which can be used in adobe forms.

One of the function is current-date(). I tried using it in event initialize for a date fild but it doesn't give any output. If i use Date(), it gives the current date with day and time.

If i use var v1 = Num2Date(Date(), "YYYY-MM-DD") it also doesn't give any value.

I am confused at to which functions can be used in adobe forms-java script.

P.S. The alternative provided by Varun Vadnala is working but my aim is identify if the Date functions can be used or not.

Thanks,

Shilpa Bansal.