Questions tagged [html-input]

The input element represents a typed data field, usually with a form control to allow the user to edit the data.

The input tag in HTML specifies an input field where the user can enter data.

<input> elements are used within a <form> element to declare input controls that allow users to input data.

An input field can vary in many ways, depending on the type attribute.

Tips and Notes

Note: The <input> element is empty, it contains attributes only and no closing </input> tag.

Tip: Use the <label> element to define labels for <input> elements.

607 questions
4126
votes
38 answers

Change a HTML5 input's placeholder color with CSS

Chrome supports the placeholder attribute on input[type=text] elements (others probably do too). But the following CSS doesn't do anything to the placeholder's value: input[placeholder], [placeholder], *[placeholder] { color: red…
David Murdoch
  • 82,194
  • 38
  • 141
  • 186
2393
votes
19 answers

Disable/enable an input with jQuery?

$input.disabled = true; or $input.disabled = "disabled"; Which is the standard way? And, conversely, how do you enable a disabled input?
omg
  • 123,990
  • 135
  • 275
  • 341
1737
votes
15 answers

When looking at most sites (including SO), most of them use: instead of: What are the main differences between the two, if any? Are there valid reasons to use one instead of the other? Are there valid…
Aron Rotteveel
  • 73,917
  • 17
  • 100
  • 128
1096
votes
20 answers

Best way to remove an event handler in jQuery?

I have an input type="image". This acts like the cell notes in Microsoft Excel. If someone enters a number into the text box that this input-image is paired with, I setup an event handler for the input-image. Then when the user clicks the image,…
Randy L
  • 13,549
  • 12
  • 41
  • 72
1050
votes
13 answers

Get the value in an input text box

What are the ways to get and render an input value using jQuery? Here is one: $(document).ready(function() { $("#txt_name").keyup(function() { alert($(this).val()); }); })
Bharanikumar
  • 24,127
  • 48
  • 126
  • 191
992
votes
15 answers

How do I get the value of text input field using JavaScript?

I am working on a search with JavaScript. I would use a form, but it messes up something else on my page. I have this input text field: And this is my…
user979331
  • 10,209
  • 56
  • 186
  • 339
635
votes
36 answers

Disable Auto Zoom in Input "Text" tag - Safari on iPhone

I made an HTML page that has an tag with type="text". When I click on it using Safari on iPhone, the page becomes larger (auto zoom). Does anybody know how to disable this?
Eduardo Montenegro
  • 6,359
  • 3
  • 13
  • 3
544
votes
13 answers

HTML input - name vs. id

When using the HTML tag, what is the difference between the use of the name and id attributes especially that I found that they are sometimes named the same?
Simplicity
  • 41,347
  • 81
  • 231
  • 358
505
votes
17 answers

Set the value of an input field

How would you set the default value of a form text field in JavaScript?
SebastianOpperman
  • 5,680
  • 5
  • 28
  • 35
454
votes
9 answers

What's the proper value for a checked attribute of an HTML checkbox?

We all know how to form a checkbox input in HTML: What I don't know -- what's the technically correct value for a checked checkbox? I've seen these all work:
buley
  • 24,595
  • 17
  • 76
  • 99
395
votes
9 answers

CSS selector for text input fields?

How can I target input fields of type 'text' using CSS selectors?
Yarin
  • 144,097
  • 139
  • 361
  • 489
361
votes
9 answers

How do I make a text input non-editable?

So I have a text input Here is my CSS for it background:url("images/number-bg.png") no-repeat scroll 0 0 transparent; border:0 none; color:#FFFFFF; height:17px; margin:0 13px 0…
Matt Elhotiby
  • 39,076
  • 79
  • 210
  • 312
244
votes
7 answers

How to align texts inside of an input?

For all default inputs, the text you fill starts on the left. How do you make it start on the right?
phz
  • 3,073
  • 3
  • 12
  • 15
208
votes
29 answers

change type of input field with jQuery

$(document).ready(function() { // #login-box password field $('#password').attr('type', 'text'); $('#password').val('Password'); }); This is supposed to change the #password input field (with id="password") that is of type password to a…
Richard Knop
  • 73,317
  • 142
  • 374
  • 539
204
votes
14 answers

How to set default value to the input[type="date"]

I have tried (JSFiddle): but it doesn't work, how can I set the default value?
hh54188
  • 13,085
  • 30
  • 99
  • 174
1
2 3
40 41