Expand my Community achievements bar.

Date format (mm/dd/yyyy) for LiveCycle Designer form

Avatar

Level 2

Hi,

I am working on the 35 pages Dynamic LiveCycle form where I am having many date fields (DOB, DOO and DOJ).

Sometimes, the user enters the date manually instead selecting the dropdown. Suppose, if they start entering the value manually should get a popup showing "Please use the Dropdown instead of manually entering the date." So, it doesn't allow the user to enter the value manually.

Once the user selected the date from the dropdown, the format of the date should be (mm/dd/yyyy).

Can anyone help me with the JavaScript code?

Thanks in advance.

3 Replies

Avatar

Level 10

You better use a set of edit patterns to allow multiple ways to enter a date instead of bothering users everytime with a message box.

Here's a example: LiveCycle Blog: Flexible Datumseingabe durch Datumsmuster//Flexible input of dates with date pattern...

Avatar

Level 2

Thanks for you help.

There should be ways of entering the value in the date field:

1) if the user manually enter the value, the format should be (MM/DD/YYYY), if he entered the wrong format we need to show a pop-up stating format is wrong and the value should be blank. So, the user should enter the value again with correct format.

Pop-Up Message ("Incorrect date format").

2) The user has to select the date from the dropdown since I'm using the date field.

if I validate the pattern date{MM/DD/YYYY} the user will not be able to select the dropdown.

if you could help me with some javascript code will be very useful for me to make the form more interactive.

Avatar

Level 7

Here is how I solved it on a form I had created. I had a hidden field and on the calculate event following triggered. It may have also worked on an exit event. I do not recall why I did not do it on an exit event

var myRegExp = /[0-1][0-9]\/[0-3][0-9]\/\d{4}/; // Created a regular expression for the date format

var myText = ExecFromDate.rawValue;

if(ExecFromDate.rawValue == null){

ExecFromDate.rawValue = null;

}

else

if(myRegExp.test(myText)== false){

xfa.host.messageBox("You have entered an incorrect date format. Please use MM/DD/YYYY", "Date error", 3, 0);

xfa.host.setFocus("ExecFromDate") //sets focus to the field.

ExecFromDate.rawValue = "" //resets the field to null if the patter is wrong.

}