Hello all, I need some guidance...
Using
Struts,
jsp, AJAX,
java.
Scenario: I have a page with text fields - 3 of these fields work together, meaning if you enter data into one of these fields, then LOSE FOCUS via tab or click out, AJAX fires, goes to the server 'validate' method in the action, and recalculates/resets the other two fields.
The problem is if when you are in one of these fields and change the value but do not lose focus to fire validation, BUT hit the enter key, the submit method fires. When this happens, this field is not validated, and the other two fields are not being recalculated and now contain old calculations.
There is code that is already detecting keyCode = 13, then proceeds to submit the form. Is there a way, first thing inside of the keyCode/13 block, to fire off server validation for this one field, then based on the success of the validation (as if the field has lost focus and validated normally), continue with the submit or return back ?
Or, asked another way, is there a way to force the onchange event / validation of the changed field BEFORE the submit occurs, after hitting the enter key ?
I hope this is clear enough, I apologize if not as I am new to Javascript altogether.
Many Thanks!