-1
I need to check if the form has changed, that is, if any input data has been changed, etc.
So that when you do the submit
, or leave the page, perform some button click, or the menu be informed to the user that the data has been changed, and that it has not yet been saved.
I located this link, but I do not know if it is possible, I wanted that in any click that was not the Ubmit of the page and had made the change the user was notified, to do this I have to call the function
in several places, or there is a function that does this general on the page of form
?
You could put at least one code you’ve developed?
– João Pedro Schmitz
@Joãopedroschmitz in any
form
i want to do the validation ofinput
– Mariana
If you use the event
onchange
in all fields, it will give an alert whenever it has been modified. Ai then you validate to show the alert only if the person has not saved. Only to do it the way you said it is very annoying, unless it comes all filled, after all whenever someone tampers with any input he will accuse the alert. The ideal would be to warn that it was not saved at the time of Submit.– Máttheus Spoo
@Máttheusspoo then and how can I do it ? in a quick way without having to touch all the fields ?
– Mariana
It’s such a simple thing. But without seeing the code it gets complicated to make an example. Make a
onsumbit
, in prevents the Submit from happening with thee.preventDefault()
, check that everything has been saved (that part I don’t know how to do without seeing how you save).if( /*foi salvo */ ) { form.submit() } else { alert('salve todos os campos!') }
. If that’s what you want and you still don’t know how to do, put your code and I’ll make an example– Máttheus Spoo