L
L
lexstile2021-06-30 02:13:41
React
lexstile, 2021-06-30 02:13:41

How to make inactive button on form submission if none of the form value has changed?

There are several form fields with a submit button.
We do not use any libraries that simplify the work with forms.
I want that if the user did not change the values ​​of the fields, the button would be disabled.
If you change at least one, then make it active.

I could store initial values ​​​​in state and each time check if the value has changed (a form of 3 fields).
Is there a better and easier way to solve this problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question