Date format (mm/dd/yyyy) for LiveCycle Designer form | Community
Skip to main content
vigneshs5397046
Level 2
October 8, 2018
Question

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

  • October 8, 2018
  • 3 replies
  • 6226 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

radzmar
Level 10
October 8, 2018

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 patterns

vigneshs5397046
Level 2
October 9, 2018

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.

Level 7
October 9, 2018

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.

}