What's the difference between readonly and disabled in form controls? I found myself asking this question when implementing a very specific feature.
I'm making a form to send data, but I also want to include some generic information that the user doesn't need to enter. So I added another <input>
element and gave it a visually-hidden
class. But then I was faced with a question...do I set it to disabled
or readonly
?
After consulting this thread, I settled on readonly
because it appears that the value of disabled
inputs won't be sent when the form is submitted.