Thanks for the info Dave. I tried that but it still seems to be giving me a problem. What's happening is if I put in bad data and hit tab it gives me the error message and when I hit enter or click the OK button it gives me focus back to the offending field. So far so good. The problem is if I have bad data in the field and press the enter key and then press the enter key again twice (instead of tab) the field loses focus and I can tab or mouse out with the bad data left in the field. It's strange... I guess most users won't try to break it, but it should work. I wonder if I should put the code in the enter event...
In some cases, automatically clearing the field is a good option, but in other cases I would consider it "user abuse". If someone mistypes a credit card number, for example, they will want to go back and fix the typo rather than type in the whole thing again.
The way LiveCycle handles validations is to bark at the user as they exit the field, but allow the user to continue filling out the form. However, LiveCycle will prevent the user from submitting the form if there are validation errors. The user can still save and can still print. Often my clients want to prevent printing and saving unless the form is valid, but there's no simple way to do that. One option is to put a conspicuous marker on the form (DRAFT or WORK IN PROGRESS watermark on the master page, for example) that indicates that the form is incomplete. You can clear the watermark when the form is valid (i.e. xfa.form.execValidate() returns true).
Thanks Dave and Jared. Yes. I agree. The user shouldn't have to retype a whole entry if there is just one character off. But there should also be a way to force validation of a field before the focus is lost. In our case though we, are uploading the form instead of submitting it (which I'd like to change) so there really isn't a way to validate it like I would want. It seems that everytime there's one solution to a problem another one crops up. For instance, I was able to use a Date field and control the way it's displayed etc in Designer, but I can't force the entry to be valid before tabbing off. So then I go to a script and I can't control the display output, but I can force the way the date is entered. But then I find there's still a way to get by the field by hitting enter a few times. It's frustrating! Well, I'm ranting... I'll try the 'Draft' watermark idea and see if I can get a submit button put on the form.