I have a form that a client wishes to use where two fields might be intermixed by users. In the event either of two fields are filled, they want a lookup to be performed to a database and it uses a stored procedure we configured for the express purposes of having it try both fields until it finds the first response.
I have it currently set up so that on the change of either of these fields, it will take that value, store it to a hidden field, and perform the lookup so that the value in the starting field is able to be overwritten.
It was not until the testing user found that if one of those two fields were to be filled in and the new value would be changed, it would perform the lookup again, or in cases where the returned value were empty, it would blank out the fields.
I am hoping to find out if anyone can recommend a way to ensure that the lookup is not causing the change to the field, causing it to perform the lookup actions again.
I have included below a sample of what my code looks like now for the fields.
.LookupValue { display:none; }
function triggerLookup(fieldValue) { $('.LookupValue input').val(fieldValue); $('.LookupValue input').trigger('change'); } function triggerLookupF1(){ triggerLookup($('.F1 input').val()); } function triggerLookupF2(){ triggerLookup($('.F2 input').val()); } $('.F1').on('change','input',triggerLookupF1); $('.F2').on('change','input',triggerLookupF2);
Does anyone have a recommendation on how to handle this so the users will have the functionality they need? The form should never be able to be submitted unless this lookup is performed and these fields are filled, so an instance where it is blanking out the fields is not what they are looking for.