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.

757 questions
4350
votes
42 answers

Change an HTML input's placeholder color with CSS

Chrome v4 supports the placeholder attribute on input[type=text] elements (others probably do too). However, the following CSS doesn't do anything to the placeholder's value: input[placeholder], [placeholder], *[placeholder] { color: red…
David Murdoch
  • 87,823
  • 39
  • 148
  • 191
2533
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
  • 136,412
  • 142
  • 288
  • 348
1215
votes
16 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
  • 11,039
  • 73
  • 223
  • 418
1143
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
  • 14,384
  • 14
  • 44
  • 73
1112
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
  • 25,457
  • 50
  • 131
  • 201
844
votes
39 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
  • 8,449
  • 3
  • 16
  • 3
633
votes
18 answers

Set the default value of an input field

How would you set the default value of a form text field in JavaScript?
SebastianOpperman
  • 6,988
  • 6
  • 30
  • 36
579
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
  • 47,404
  • 98
  • 256
  • 385
481
votes
10 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
  • 28,032
  • 17
  • 85
  • 106
438
votes
8 answers

CSS selector for text input fields?

How can I target input fields of type 'text' using CSS selectors?
Yarin
  • 173,523
  • 149
  • 402
  • 512
391
votes
12 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
  • 43,028
  • 85
  • 218
  • 321
329
votes
10 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
  • 4,043
  • 3
  • 15
  • 17
254
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
  • 14,887
  • 32
  • 113
  • 184
249
votes
16 answers

Phone: numeric keyboard for text input

Is there a way to force the number keyboard to come up on the phone for an ? I just realized that in HTML5 is for “floating-point numbers”, so it isn’t suitable for credit card numbers, ZIP codes, etc. I want…
Tami
  • 3,221
  • 2
  • 18
  • 15
215
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
  • 81,041
  • 149
  • 392
  • 552
1
2 3
50 51