I am disabling the inputs using the isFetching
prop, but this is getting reduntant as I have to keep this in every input field. Is there a way to disable the entire form? Like a disable
property in <form>
tag or something?
<form> <input type="text" disabled={this.props.isFetching} /> <input type="text" disabled={this.props.isFetching} /> </form>
You should insert your form inside an element <fieldset disabled="disabled"> . This will make the whole form disabled.
To disable all form elements inside 'target', use the :input selector which matches all input, textarea, select and button elements.
To disable an input field inside a <Form /> function component, we will use isDisabled local state and it's setter method setIsDisabled , defined using the useState() hook.
The disabled attribute can be set to keep a user from using the <input> element until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the <input> element usable. Tip: Disabled <input> elements in a form will not be submitted!
I think this should solve your problem https://stackoverflow.com/a/17186342/3298693.
You should insert your form inside an element <fieldset disabled="disabled">
. This will make the whole form disabled.
I had the same issue and this worked for me:
<fieldset disabled={true}>
Where true would be some "prop.setting"...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With