DevExtreme v23.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Limit the String Length

To limit the string length, assign an integer number to the maxLength option. By default, the string length is unlimited.

jQuery
JavaScript
$(function() {
    $("#textBoxContainer").dxTextBox({
        maxLength: 10
    });
});
Angular
HTML
TypeScript
<dx-text-box
    [maxLength]="10">
</dx-text-box>
import { DxTextBoxModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxTextBoxModule
    ],
    // ...
})
React
import React from 'react';
import { TextBox } from 'devextreme-react/text-box';

class App extends React.Component {
    render() {
        return (
            <TextBox
                maxLength={10}
            />
        );
    }
}

export default App;
See Also