You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an issue with Solid.js where the disabled state of a button is not updating correctly based on the length of an input field.
Here’s a minimal example of my code:
import{createSignal,createMemo}from'solid-js';constFeedbackForm=()=>{const[text,setText]=createSignal('');const[msg,setMsg]=createSignal('');constbtnDisabled=createMemo(()=>text().trim().length<=20);consttextHandler=(e)=>{setText(e.target.value);};constformSubmit=(e)=>{e.preventDefault();if(!btnDisabled()){// Handle form submission}};return(<divclass="container"><formonSubmit={formSubmit}><inputtype="text"placeholder="Write your feedback here"onInput={textHandler}value={text()}/><buttontype="submit"class="btn btn-secondary"disabled={btnDisabled()}>
Submit
</button>{msg()&&<span>{msg()}</span>}</form></div>);};exportdefaultFeedbackForm;
The button remains disabled even when the input length exceeds 20 characters. Any ideas on what might be wrong?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm encountering an issue with Solid.js where the disabled state of a button is not updating correctly based on the length of an input field.
Here’s a minimal example of my code:
The button remains disabled even when the input length exceeds 20 characters. Any ideas on what might be wrong?
Thanks in advance for your help!
Beta Was this translation helpful? Give feedback.
All reactions