Your search did not match any results.

Text Box

The TextBox is a UI component that allows users to enter and edit a single line of text.

Backend API
<div class="form"> <div class="dx-fieldset"> <div class="dx-field"> <div class="dx-field-label">Default mode</div> <div class="dx-field-value"> @(Html.DevExtreme().TextBox() .Value("John Smith") .InputAttr("aria-label", "Name") ) </div> </div> <div class="dx-field"> <div class="dx-field-label">With placeholder</div> <div class="dx-field-value"> @(Html.DevExtreme().TextBox() .Placeholder("Enter full name here...") .InputAttr("aria-label", "Full Name") ) </div> </div> <div class="dx-field"> <div class="dx-field-label">With clear button</div> <div class="dx-field-value"> @(Html.DevExtreme().TextBox() .Value("John Smith") .InputAttr("aria-label", "Name") .ShowClearButton(true) ) </div> </div> <div class="dx-field"> <div class="dx-field-label">Password mode</div> <div class="dx-field-value"> @(Html.DevExtreme().TextBox() .Mode(TextBoxMode.Password) .Value("f5lzKs0T") .Placeholder("Enter password") .InputAttr("aria-label", "Password") .ShowClearButton(true) ) </div> </div> <div class="dx-field"> <div class="dx-field-label">Text mask</div> <div class="dx-field-value"> @(Html.DevExtreme().TextBox() .Mask("+1 (X00) 000-0000") .InputAttr("aria-label", "Mask") .MaskRules(new { X = new JS("/[02-9]/") }) ) </div> </div> <div class="dx-field"> <div class="dx-field-label">Disabled</div> <div class="dx-field-value"> @(Html.DevExtreme().TextBox() .Value("John Smith") .InputAttr("aria-label", "Name") .Disabled(true) ) </div> </div> </div> <div class="dx-fieldset"> <div class="dx-fieldset-header">Events and API</div> <div class="dx-field"> <div class="dx-field-label">Full Name</div> <div class="dx-field-value"> @(Html.DevExtreme().TextBox() .Value("Smith") .ShowClearButton(true) .Placeholder("Enter full name") .InputAttr("aria-label", "Full Name") .ValueChangeEvent("keyup") .OnValueChanged("textBox_valueChanged") ) </div> </div> <div class="dx-field"> <div class="dx-field-label">Email (read only)</div> <div class="dx-field-value"> @(Html.DevExtreme().TextBox() .ID("email") .Value("") .InputAttr("aria-label", "Email") .ReadOnly(true) .HoverStateEnabled(true) ) </div> </div> </div> </div> <script> function textBox_valueChanged(data) { $("#email") .dxTextBox("instance") .option("value", data.value.replace(/\s/g, "").toLowerCase() + ""); } </script>
using System.Web.Mvc; namespace DevExtreme.MVC.Demos.Controllers { public class TextBoxController : Controller { public ActionResult Overview() { return View(); } } }

This demo illustrates the following TextBox properties:

  • value
    A value the TextBox displays.

  • placeholder
    An input prompt the TextBox displays when the value is not defined.

  • showClearButton
    Specifies whether to display the button that clears the TextBox value.

  • mode
    Affects a set of keyboard characters displayed on a mobile device when the TextBox gets focus and modifies the component's display style. In this example, the mode is set to "password" so that entered characters are obscured, and the password cannot be read.

  • mask
    An input mask.

  • maskRules
    Custom mask rules.

  • disabled
    Specifies whether the TextBox responds to user interaction.

  • onValueChanged event handler
    Use this function to perform an action when a user enters a new value. In this demo, this function uses the entered value to construct a dummy email address and assign it to another TextBox.

  • valueChangeEvent
    One or several DOM events that trigger the onValueChanged event handler.

  • readOnly
    Prevents users from changing the editor's value.

  • hoverStateEnabled
    Specifies whether the TextBox responds when users long press or hover the mouse pointer over it.