I'm having a really weird behaviour on a form.
There is a number of text fields with in-line validation, showing an error message below the field if the content is invalid. The validation is triggered on blur.
At the bottom of the page there is a "Next" button. On click, a validation is performed and, if everything is ok, the form is submitted.
Now, if a mandatory, empty field has focus when I click the button the following happens:
- onBlur is triggered and in-line validation is performed
- the error message is displayed
- the rest of the page is "pushed down" to show the error text
- the onClick action on the button is NOT triggered
I initially thought that onBlur was somehow preventing onClick. Then I've noticed that when the page moves down, the mouse pointer is no more ON the button as this is pushed down. If I click on the button in a low enough position, such that after the "moving" the pointer is still on the button, onClick is triggered.
I replaced the onClick with onMouseDown and the problem is fixed, but I am really puzzled by the reason this happens.