Hello,
We want to validate a VAT number in a custom field. With javascript we validate the VAT number in the OnChange method of that field.
When the validation fails, an error message is shown and the focus is set back on the VAT number field with:
Xrm.Page.getControl("new_vatnumber").setFocus();
Now the problem: when the focus is set to the VAT number field after the validation and we change the content and click outside the field, we would expect the onchange event to be triggered again. This does not happen. Only when we use the "tab" key,the onChange event is triggered again.
Also when we click in other fields after the setFocus, the VAT field still seems to have focus (the border is still visible).
I have tried serveral options found on the internet, but none seem to fix the problem.
For example setting the event.ReturnValue to false in the onChange event.
Below is a screenshot where you see that when another field is selected the VAT field still seems to have focus.
Thank you in advance.






