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

Problem setting maximum characters for a date field.

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

19-06-2013

Good morning all. I am trying to ensure that a date field on the form I am working on validates if the entry is not more than 8 digits, and if it is more, it should display a message, and return the focus back to the field until it is correct. Below is the code I wrote but it is not working:

  

if(DATE1.length>"8"){

    xfa.host.messageBox(Enter eight digits for the date in the format YYYYMMDD or use the drop down calendar.);

xfa.host.setFocus("form1.Page1.DATE1");

  }

I do not know why it is not working, i need help. I have this code on the exit event.

Thanks

v/r

Tammy

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

19-06-2013

I won't do this, because you'll frustrate users if there is a message shown every time they enter a wrong format.

Better you allow as many pattern as possible.

Here's an explaination:

http://thelivecycle.blogspot.de/2011/10/date-patterns.html

Avatar

Avatar
Validate 1
Level 5
whyisthisme
Level 5

Likes

41 likes

Total Posts

324 posts

Correct Reply

59 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 5
whyisthisme
Level 5

Likes

41 likes

Total Posts

324 posts

Correct Reply

59 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
whyisthisme
Level 5

19-06-2013

Well you are missing the " around the text in your messagebox but even then it doesn't seem to work. I am not a javascript expert so am not sure why but it works in formcalc like this:

if(Len($) > 😎 then

    xfa.host.messageBox("Enter eight digits for the date in the format YYYYMMDD or use the drop down calendar.")

    xfa.host.setFocus("$")

endif