UI Widgets TextBox

A single-line text box widget.

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/text_box
TextBox interactive configuration
Copy code
$("#textbox").dxTextBox({
});

The TextBox widget enables a user to enter a single line of text.

You can create a widget using one of the following approaches.

  • jQuery
    Use the dxTextBox jQuery plug-in.

    HTML
    <div id="textBox"></div>
    JavaScript
    $("#textBox").dxTextBox({
        placeholder: 'Type password',
        maxLength: 10,
        mode: 'password'
    });
  • Knockout
    Add a div element and apply the dxTextBox binding to this element.

    HTML
    <div data-bind="dxTextBox: {
        placeholder: 'Type password',
        maxLength: 10,
        mode: 'password'
    }"></div>
  • AngularJS
    Add a div element and apply the dx-text-box directive to this element.

    HTML
    <div dx-text-box="{
        placeholder: 'Type password',
        maxLength: 10,
        mode: 'password'
    }"></div>

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the Installation article.

You can find detailed information on the principles of working with the widget in the dxTextBox section of the Editor Widgets article.

View Demo

Show Example:
AngularJS
Knockout
jQuery
<div ng-controller="demoController" class="dx-fieldset">
    <div class="dx-field">
        <div class="dx-field-label">Maxlength</div>
        <div class="dx-field-value" dx-text-box="{
            maxLength: length,
            placeholder: lengthDescription
        }"></div>
    </div>
    <div class="dx-field">
        <div class="dx-field-label">Password</div>
        <div class="dx-field-value" dx-text-box="{
            mode: passMode,
            placeholder: secretDescription
        }"></div>
    </div>
        <div class="dx-field">
        <div class="dx-field-label">Read-only</div>
        <div class="dx-field-value" dx-text-box="{
            readOnly: readonly,
            value: readonlyDescription
        }"></div>
    </div>
</div>
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
    $scope.length = 10;
    $scope.lengthDescription = "10 characters maximum";

    $scope.passMode = "password";
    $scope.secretDescription = "type a password";

    $scope.readonly = true;
    $scope.readonlyDescription = "read-only text box";
});
angular.element(document).ready(function () {
    angular.bootstrap(document, ['myApp']);
});
<div class="dx-fieldset">
    <div class="dx-field">
        <div class="dx-field-label">Maxlength</div>
        <div class="dx-field-value" data-bind="dxTextBox: {
            maxLength: length,
            placeholder: lengthDescription
        }"></div>
    </div>
    <div class="dx-field">
        <div class="dx-field-label">Password</div>
        <div class="dx-field-value" data-bind="dxTextBox: {
            mode: passMode,
            placeholder: secretDescription
        }"></div>
    </div>
    <div class="dx-field">
        <div class="dx-field-label">Read-only</div>
        <div class="dx-field-value" data-bind="dxTextBox: {
            readOnly: readonly,
            value: readonlyDescription
        }"></div>
    </div>
</div>
var myViewModel = {
    length: 10,
    lengthDescription: "10 characters maximum",

    passMode: "password",
    secretDescription: "type a password",

    readonly: true,
    readonlyDescription: "read-only text box"
}
ko.applyBindings(myViewModel);
<div class="dx-fieldset">
    <div class="dx-field">
        <div class="dx-field-label">Maxlength</div>
        <div class="dx-field-value" id="myTextBox1"></div>
    </div>
    <div class="dx-field">
        <div class="dx-field-label">Password</div>
        <div class="dx-field-value" id="myTextBox2"></div>
    </div>
    <div class="dx-field">
        <div class="dx-field-label">Read-only</div>
        <div class="dx-field-value" id="myTextBox3"></div>
    </div>
</div>
$("#myTextBox1").dxTextBox({
    maxLength: 10,
    placeholder: "10 characters maximum"
});
$("#myTextBox2").dxTextBox({
    mode: "password",
    placeholder: "type a password"
});
$("#myTextBox3").dxTextBox({
    readOnly:true,
    value: "read-only text box"
});

Configuration

An object defining configuration options for the TextBox widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.