Html button and onchange

There is a fairly simple html application.

Changing the text field will send, following the redraw. Pressing the button will also send.

When changing the field and leave it by clicking the button, the browser will encounter a conflict. The browser starts one submit, interrupts it and performs the next submit. The result is unreliable.

Is there a simple solution for getting a single message with a button and a field without switching to some AJAX approach (say GWT)?

+4
source share
2 answers

You can cancel any other event handler when submitting the form. This is similar to disabling submission after clicking on it, to prevent the form from being submitted twice by impatient users.

+1
source

You can send a flag that will indicate if the send function called once, if the sender has already been called, and then do not call submit for this user.

OR you can disable the submit button as soon as you call the function from the text field, so the user will not be able to click the submit button.

Can help you

0
source

Source: https://habr.com/ru/post/1442001/


All Articles