Create a input textbox without using <input type="text">
Solution 1
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" />
Solution 2
You could use a contenteditable div, too.
From the MDN:
<!DOCTYPE html>
<html>
<body>
<div contenteditable="true">
This text can be edited by the user.
</div>
</body>
</html>
http://html5demos.com/contenteditable
Solution 3
you can use a textarea
instead of input
. then apply stlying with css. also you can use your input tag, just keep it outside the <form></form>
then it won't be send over to the server.
Solution 4
just create the input, and don't give it a name
or id
.
Solution 5
if you create dynamic <input type="text">
by jQuery - it WILL post back its values.
What do you care if its values are posted back ? just dont do anything with them in the server side.
or ,
before submit - change the type from input to label. ( + save values)
or ,
if youll add the input OUTSIDE the FORM element - it wont submit.
Nyxynyx
Hello :) I have no formal education in programming :( And I need your help! :D These days its web development: Node.js Meteor.js Python PHP Laravel Javascript / jQuery d3.js MySQL PostgreSQL MongoDB PostGIS
Updated on June 05, 2022Comments
-
Nyxynyx almost 2 years
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
?