I want to create a input textbox that does not require a <input type="text">
form element. The user can still type text into this textbox and the value can still be retrieved using Javascript/jQuery. The reason for doing this is because this textbox will be in a form that upon submit, all form input values will be sent to the server side for processing, and there is this textbox that I dont want its values to be automatically send to server side.
Problem: What is the best way to create such a textbox without relying on HTML form elements input
?
The readonly attribute makes a form control non-editable (or “read only”). A read-only field can't be modified, but, unlike disabled , you can tab into it, highlight it, and copy its contents. Setting the value to null does not remove the effects of the attribute. Instead use removeAttribute('readonly') .
Yes, you can have a valid input without a form.
Just don't give the <input type="text">
tag a name
attribute and it won't submit. Here is an example:
<input type="text" id="myinput" value="you will not see this submitted" />
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