xfa.host.SetFocus question.

Avatar

Avatar
Validate 10
Level 2
1996_kcv
Level 2

Likes

2 likes

Total Posts

85 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 1
View profile

Avatar
Validate 10
Level 2
1996_kcv
Level 2

Likes

2 likes

Total Posts

85 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 1
View profile
1996_kcv
Level 2

25-11-2011

 

I have a code on Exit event of the field that checks if 5 digit US ZIP code, 5 digit US ZIP code + 4, and 6 digit alphanumeric Canadian Postal Code.

If user enters valid 5 digits code, then I set focus to specific field-FField1. Code is simple and it works. What does not work is, if I tab out , without entering anyting in the Zip code, the focus is set to some other field, not FField1. How can I force it with the code that focus is set to FField1 all the time.

Code is simple:

var regExpDate = /^\^\d{5}-\d{4}|\d{5}|[A-Z]\d[A-Z] \d[A-Z]\d$ $/;
var vMatched = this.rawValue.match(regExpDate);
if (!vMatched){
this.rawValue=null;
xfa.host.messageBox("Enter the following format: 99999 or 99999-9999 or A9A 9A9 );
xfa.host.setFocus(this);
}

else
{
xfa.host.setFocus(form1.subform1.FField1);
}

 

 

 

View Entire Topic

Avatar

Avatar
Give Back 3
Level 2
past-tense
Level 2

Likes

9 likes

Total Posts

85 posts

Correct reply

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

Avatar
Give Back 3
Level 2
past-tense
Level 2

Likes

9 likes

Total Posts

85 posts

Correct reply

10 solutions
Top badges earned
Give Back 3
Give Back
Validate 1
Boost 5
Boost 3
View profile
past-tense
Level 2

25-11-2011

No worries, this forum has helped me out a number of times, and I like to show my appreciation by helping others when I can.

As for the commitKey code not working, I've seen this happen when it's used with javascript instead of formcalc. It's not a huge issue, and converting your validation from javascript to formcalc may not be worth the trouble you would have doing so. For other fields, though, you could try putting the following code in formcalc instead of using javascript, just to see if using formcalc fixes this issue for you:

if (xfa.event.commitKey == 3) then

     xfa.host.setFocus("$.parent.NextFieldName");

endif

My break is ending, though, so I need to sign off. Good luck with your form,

- Scott