Copy link to clipboard
Copied
I'm running JavaScript validations on form fields to show and hide follow on fields based on user input from the dropdown menu. The problem I'm having is that if the user confirms the value using Tab, the cursor gets lost on the document and starts over at the first field instead of continuing to the next field beyond the now hidden field. I tried using getNext to no avail. The dropdown defaults to a blank space so it could be printed as a blank form, followed by a checkmark, an "X", and finally a "/". Selecting "/" identifies that the subfields are not required and while the user could simply tab through them, I'm trying to make it easier on the user. Any help would be appreciated. Here's a sample of the code:
if (event.value == " /") {
this.getField("EGI GROUND CHECK").display = display.hidden;
goNext(this, event, "BEFORE 7");
}
else {
this.getField("EGI GROUND CHECK").display = display.visible;
goNext(this, event, "EGI GROUND CHECK");
}
I couldn't get that specific code to work since it was for a combed field, but after a little more trial and error, I was able to get it to work. I kept it as a custom validation script. When I tried it as a custom keystroke, I couldn't figure out how to stop it from executing the script the moment ANY selection was made with the arrow keys instead of the final selection. I may have been using the wrong command (event.commitKey v. event.commitOn). Thank you both for the help.
if (event.value
...Copy link to clipboard
Copied
What is your definition of goNext?
What action is this script attached to (if it's on validation, move it; side effects on validation tend to be a bad idea)?
Copy link to clipboard
Copied
I think I understand what you're saying, but I'll be the first to admit I'm learning this as I go through a lot of Google and trial and error. I've attached some screenshots that will hopefully answer what you were asking.
Copy link to clipboard
Copied
Ok, thanks, see how you call your script, but what is the definition of goNext? You must have put it in the document, I think.
Copy link to clipboard
Copied
That may be where I'm messing up. goNext isn't defined anywhere. The only place I used it in any JS was there where you saw it.
Copy link to clipboard
Copied
It should be a function located in the Document Level script section since it will be called from many different fields. It was originally written by Carl Orthlieb and posted as JavaScript - setFocus Method for tabbing to next form field. The original script was designed to fill-in comb fields with numbers and tab to the next field as each number was entered. The script is usually called from a custom keystroke event.It is possible to modify the script to allow alphanumeric and special characters.
Copy link to clipboard
Copied
I couldn't get that specific code to work since it was for a combed field, but after a little more trial and error, I was able to get it to work. I kept it as a custom validation script. When I tried it as a custom keystroke, I couldn't figure out how to stop it from executing the script the moment ANY selection was made with the arrow keys instead of the final selection. I may have been using the wrong command (event.commitKey v. event.commitOn). Thank you both for the help.
if (event.value == " /") {
this.getField("EGI GROUND CHECK").display = display.hidden;
this.getField("BEFORE 7").setFocus();
}
else {
this.getField("EGI GROUND CHECK").display = display.visible;
this.getField("EGI GROUND CHECK").setFocus();
}