Question

Consider the following form:

<form action="/a" method="post"> 
    <input name="x" type="text" onblur="myonblur(e)" />
    <input name="y" type="text" />
    <input name="submit" type="submit" value="Submit" />
</form>

When focus is on element with name "x" and user presses submit button, onblur event fires but form is NOT submitted. Is there any way to make submit button work as expected if I have onblur events in my form?

Was it helpful?

Solution

Consider optimizing your onBlur() method so it takes less time to run. If your form is prevented from getting submitted, it might be because the onBlur() is too long and hangs the browser from doing anything else.

You can also use the onChange() method instead of onBlur(). That may work better for you.

OTHER TIPS

Try adding

return true;

after calling your onBlur function. The problem you are facing with might be due to "return false" prevention of the event handlers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top