New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

RadTextBox Client Object

The following tables lists the most important properties/methods of the RadTextBox client-side object:

Properties

 

NameParametersReturn TypeDescription
get_value()nonestringReturns the value of the text box.
set_value()stringnoneSets the value of the text box.
get_editValue()nonestringGets the value of the text box as it is formatted when the text box has focus.
get_displayValue()nonestringGets the value of the text box as it is formatted when the text box does not have focus.
get_textBoxValue()nonestringGets the string that the user typed into the text box.
get_caretPosition()noneintegerReturns the current position of the caret.
set_caretPosition()integernoneSets the position of the caret.
get_styles()noneInputStylesReturns the InputStyles Client object, which can be used to change the appearance of the text box when it is first loaded.
get_autoPostBack()nonebooleanReturns the value of the AutoPostBack property.
set_autoPostBack()booleannoneEnables or disables postbacks when the user changes the text in the text box.
get_enabled()nonebooleanReturns true if the text box is enabled.
get_showButton()nonebooleanReturns true if the text box has an associated image button.
get_selectionOnFocus()noneTelerik.Web.UI.SelectionOnFocusReturns the value of the SelectionOnFocus property. Possible values are Telerik.Web.UI.SelectionOnFocus.CaretToBeginning, Telerik.Web.UI.SelectionOnFocus.CaretToEnd, Telerik.Web.UI.SelectionOnFocus.None, and Telerik.Web.UI.SelectionOnFocus.SelectAll.
set_selectionOnFocus()Telerik.Web.UI.SelectionOnFocusnoneSets the SelectionOnFocus property.
get_emptyMessage()nonestringReturns the message that appears when the text box value is an empty string.
set_emptyMessage()stringnoneSets the message that appears when the text box value is an empty string.
get_element()noneHTML elementGets the DOM element for the input element that holds the edit value.
get_wrapperElement()noneHTML elementGets the DOM element for the wrapper element.
get_visible()nonebooleanReturns whether the input element is rendered as hidden or not. Does not apply if the control is inside another hidden html element.
set_visible()booleannoneSets the input element as hidden on the client
set_displayValue()stringnoneSets the value of the text box as it isformatted when the text box does not have focus.

Methods

 

NameParametersReturn TypeDescription
selectAllTextnonenoneSelects all text in the text box.
selectTextinteger, integernoneSelects the text in the specified range of positions. The first parameter is the start of the range and the second is the end of the range.
enablenonenoneEnables the text box.
disablenonenoneDisables the text box.
focusnonenoneSets focus to the text box so that the user can edit its value.
blurnonenoneRemoves focus from the text box, moving it to the next control in the tab order of the page.
clearnonenoneSets the value of the text box to an empty string.
isMultiLinenonebooleanReturns true if the text mode is MultiLine.
isReadOnlynonebooleanReturns true of the text box is read-only.
isEmptynonebooleanReturns true if the value of the text box is an empty string.

Examples

Below you will find several samples, demonstrating some basic scenarios which can be achieved by using the RadTextBox Client-side API:

## Decorate RadTextBox HTML element In this sample you will see how to change the background colour of the TextBox element, accessing it through the get_element() method:

JavaScript
<script type="text/javascript">
        function decorate() {
            var textBoxEl = $find("RadTextBox1").get_element();
            textBoxEl.style.backgroundColor = "red"
        }
</script>

## Show/Hide RadTextBox

This sample demonstrates how to change the visibility of a TextBox through the set_visible() method:

JavaScript
<script type="text/javascript">
            function showHideTextbox() {
                var textBox = $find("RadTextBox1");
                textBox.set_visible(!textBox.get_visible());
            }
</script>

## Determine if RadTextBox is empty

Here you can see how to determine if a textbox is empty, implementing some kind of a custom validation with the help of the isEmpty() method:

JavaScript
<script type="text/javascript">
            function determineIfEmpty(sender, eventArgs) {
                var emptyBox = $find('RadTextBox1');

                if (emptyBox.isEmpty()) {
                    alert('Please, enter a not empty value.');
                }
                else {
                    alert('Thank you!');
                }
            }
</script>

See Also

In this article
See Also
Not finding the help you need?
Contact Support