Question

I'm trying to create a form that automatically increments date fields by a month depending on what the user puts into the first field. I've dug through some javascript and am thinking that the issue may lie in the way Adobe date fields are formatted and what Date() in javascript accepts as input. So for this example I want what is entered in date field to increment by one month and be put into date1 field. Below is my effort.

 var two = this.getField("date1");

 var date = new Date(this.getField("date"));
 two.value = (date.getMonth() + 1) + '/' + date.getDate() + '/' +  date.getFullYear();

This is entered in date's action field.

Was it helpful?

Solution

I was able to resolve the issue by doing this and incrementing the getMonth() call and setting it to the variable before displaying the date in a formatted way.

var nDate = new Date(inputBox.value);
nDate.setMonth( nDate.getMonth( ) + 1 );
inputBox1.value = (nDate.getMonth() + 1) + "/" + (nDate.getDate()) + "/" +  (nDate.getFullYear());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top