Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Needs help with my date validation script

Avatar

Avatar
Validate 1
Level 2
lpianwi
Level 2

Like

1 like

Total Posts

69 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
lpianwi
Level 2

Like

1 like

Total Posts

69 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
lpianwi
Level 2

13-08-2013

I have date field in my form I am working on, and when the date picker is used, it works fine with the date format as YYYYMMDD. However, when it is manually entered wrong, it only pops up the error message, but tabs to the next field. Is there a script that will set the focus back to the field, and only tabs out of it when the user input is incorrect. I wrote the below script, but it is not working, and I do not know why it is not.

Create a date() for parsing information.
var sDate = Date.rawValue;
var oDate = util.scand("yyyymmdd", sDate);    
// Store date values.
var nYear = oDate.getFullYear();
var nMonth = oDate.getMonth() + 1; 
var nDay = oDate.getDate();

if(nDay > 31 || nDay < 1 || nMonth > 12 || nMonth < 1){  
   xfa.host.messageBox("Please enter the number using numerical characters only in the format YYYYMMDD");  
  xfa.host.setFocus("DateTimeField1");
}

Thanks

v/r

Tammy

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 10
Niall_O_Donovan
Level 10

Likes

646 likes

Total Posts

4,352 posts

Correct Reply

786 solutions
Top badges earned
Validate 1
Boost 500
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 1
Level 10
Niall_O_Donovan
Level 10

Likes

646 likes

Total Posts

4,352 posts

Correct Reply

786 solutions
Top badges earned
Validate 1
Boost 500
Boost 50
Boost 5
Boost 3
View profile
Niall_O_Donovan
Level 10

16-08-2013

Hi,

One option instead of a validation script is to specify multiple date patterns in the Edit tab (Object > Field palette and click Patterns).

{YYYYMMDD} | {DD-MM-YY} | {DD-MM-YYYY} | {DD/MM/YY} | {DD/MM/YYYY} | {MM-DD-YY}

The Display pattern would remain the same {YYYYMMDD}

Hope that helps,

Niall