Hi,
I have two questions about xfa.event.setFocus() and validation
1. Is there any way to determine the next field in the tab order so I can use setFocus to jump to the next field without having to put the real field name in the setFocus?
2. In my JavaScript Exit event I check the user's input and if incorrect I do a setFocus back to that field so they can try again.
When the user triggers the Exit event by tabbing, the focus works and ends up highlighting the bad data they just entered.
When the user triggers the Exit event by hitting the Enter Key the focus does not work and nothing is highlighted. I can force it to work by checking for the Enter Key with a xfa.event.commitKey and doing a setFocus to the next field in tab order and then doing a setFocus back to the original field that had the error. This does work except with a Date/Time field the setFocus back to the original field get hung up and does not work until I mouse click on another field. Why is that?
Is there a better way to do this?
Here's my sample JavaScript
F.P5.WRKPhone::exit - (JavaScript, client)
var ValPhone = /^(\d{10})$/;
if (this.rawValue != null && this.rawValue != "") {
if (! ValPhone.test(this.rawValue)) {
if (xfa.event.commitKey != 2) {
xfa.host.setFocus(this); }
else {
xfa.host.setFocus(F.P1.EmgPhone);
app.setTimeOut("xfa.host.setFocus('" + this.somExpression + "');", 10);
}
}
}
Thanks a lot for any help!
Ron
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script