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

Set focus on phone number field when validations fails

Avatar

Avatar
Validate 10
Level 3
Geckoz100
Level 3

Likes

20 likes

Total Posts

143 posts

Correct Reply

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

Avatar
Validate 10
Level 3
Geckoz100
Level 3

Likes

20 likes

Total Posts

143 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile
Geckoz100
Level 3

24-06-2015

Hello,

I have a text field set up as a phone number field, with the following in the change event to accept numbers only:


if(xfa.event.newText.match(/[^0-9]/)){


xfa.event.change = "";


}


In the Pattern validation, I have this mask on all tabs (Display, Edit, Validation and Data):

text{'('999')' 999-9999}

I want the user to be able to just enter numbers and have the parentheses and dash added automatically ["(123)-456-7890"].


How do I get the focus to stay on this field when it fails validation? (e.g., insufficient or too many digits).  I have looked into validationState but couldn't figure out how to use it (I'm a noob javascripter).

Thanks for any help.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct Reply

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

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct Reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
jasotastic81
Level 4

25-06-2015

in the exit event of your field:


if (this.rawValue.length !=9) xfa.host.setFocus(this);


Answers (2)

Answers (2)

Avatar

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct Reply

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

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct Reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
jasotastic81
Level 4

25-06-2015

Yeah, I'll learn how to count one day...

Avatar

Avatar
Validate 10
Level 3
Geckoz100
Level 3

Likes

20 likes

Total Posts

143 posts

Correct Reply

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

Avatar
Validate 10
Level 3
Geckoz100
Level 3

Likes

20 likes

Total Posts

143 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile
Geckoz100
Level 3

25-06-2015

That worked, thanks!  The only change I made was to insert "10" instead of "9" for the phone digits.


if (this.rawValue.length != 10) xfa.host.setFocus(this);