Questions tagged [textbox]

A textbox is a graphical user interface element which allows for simple input text, usually only a single line of text.

A text box, text field or text entry box is a kind of widget used when building a graphical user interface (GUI). A text box's purpose is to allow the user to input text information to be used by the program. User-interface guidelines recommend a single-line text box when only one line of input is required, and a multi-line text box only if more than one line of input may be required. Non-editable text boxes can serve the purpose of simply displaying text.

A typical text box is a rectangle of any size, possibly with a border that separates the text box from the rest of the interface. Text boxes may contain zero, one, or two scrollbars. Text boxes usually display a text cursor (commonly a blinking vertical line), indicating the current region of text being edited. It is common for the mouse cursor to change its shape when it hovers over a text box.

Wikipedia article: https://en.wikipedia.org/wiki/Text_box

Alternatively text box referred to as a text field, a text box is a section of a page that enables a user to enter text. Text boxes are often used on the Internet for pages that require input from a user. Below are some examples of text boxes you are likely to encounter.

One-line text box

A one-line text box is often used when only a few words, such as a name, are required.

single line

Scrolling text box

A scrolling text box allows a user to enter lots of data and usually scroll up, down, left, or right to view the text in the box.

multi line

In HTML, a textbox can be made with either <input type=text></input> or <textarea></textarea>.

12672 questions
147
votes
21 answers

Set focus on TextBox in WPF from view model

I have a TextBox and a Button in my view. Now I am checking a condition upon button click and if the condition turns out to be false, displaying the message to the user, and then I have to set the cursor to the TextBox control. if (companyref ==…
priyanka.sarkar
  • 25,766
  • 43
  • 127
  • 173
139
votes
7 answers

jQuery textbox change event doesn't fire until textbox loses focus?

I found that jQuery change event on a textbox doesn't fire until I click outside the textbox. HTML: JS: $("#textbox").change(function() {alert("Change detected!");}); See demo on JSFiddle My application requires…
SNag
  • 17,681
  • 10
  • 54
  • 69
134
votes
14 answers

Limit number of characters allowed in form input text field

How do I limit or restrict the user to only enter a maximum of five characters in the textbox? Below is the input field as part of my form: Is it using something like maxSize or something like…
BruceyBandit
  • 3,978
  • 19
  • 72
  • 144
133
votes
9 answers

Set focus on textbox in WPF

How to set the focus on an TextBox element in WPF I have this code: txtCompanyID.Focusable = true; txtCompanyID.Focus(); ...but it is not working. Any idea?
priyanka.sarkar
  • 25,766
  • 43
  • 127
  • 173
133
votes
20 answers

How to remove the focus from a TextBox in WinForms?

I need to remove the focus from several TextBoxes. I tried using: textBox1.Focused = false; Its ReadOnly property value is true. I then tried setting the focus on the form, so as to remove it from all the TextBoxes, but this also fails to…
Callum Rogers
  • 15,630
  • 17
  • 67
  • 90
130
votes
14 answers

How can I add a hint text to WPF textbox?

For example, Facebook has a "Search" hint text in the Search text box when the textbox is empty. How to achieve this with WPF text boxes??
Louis Rhys
  • 34,517
  • 56
  • 153
  • 221
130
votes
16 answers

How do I trigger an HTML button when the “Enter” key is pressed in a textbox?

So the code that I have so far is: It is not in a
and is just as it…
Ben
  • 2,388
  • 4
  • 18
  • 16
122
votes
12 answers

Bind TextBox on Enter-key press

The default databinding on TextBox is TwoWay and it commits the text to the property only when TextBox lost its focus. Is there any easy XAML way to make the databinding happen when I press the Enter key on the TextBox?. I know it is pretty easy to…
Jobi Joy
  • 49,102
  • 20
  • 108
  • 119
116
votes
5 answers

How do I set a textbox's text to bold at run time?

I'm using Windows forms and I have a textbox which I would occassionally like to make the text bold if it is a certain value. How do I change the font characteristics at run time? I see that there is a property called textbox1.Font.Bold but this is…
Diskdrive
  • 18,107
  • 27
  • 101
  • 167
114
votes
11 answers

WPF: How to programmatically remove focus from a TextBox

I want to add a simple (at least I thought it was) behaviour to my WPF TextBox. When the user presses Escape I want the TextBox he is editing to have the text it had when the user started editing, AND I want to remove the focus from the TextBox. I…
jpsstavares
  • 3,303
  • 5
  • 25
  • 32
113
votes
4 answers

Bug With Firefox - Disabled Attribute of Input Not Resetting When Refreshing

I've found what I believe to be a bug with Firefox and I'm wondering if this actually is a bug, as well as any workarounds for this. If you create a basic webpage with the following source: