How can we set and then reset MaxLength property for a Telerik TextBox from client side?

150 views Asked by At

I am using a RadTextBox control and I need to set an reset MaxLength property based on some conditions, in client side.

    if(maxLengthToSet == 4){ 
       txtBox.set_maxLength(4);
    }
    else{
       // reset maxlength so that it can accept up-to limits of a RadTextBox
    }

How can we reset the maxLength property or remove this property from the textBox.

1

There are 1 answers

0
Rumen Jekov On BEST ANSWER

We have already solved this at the Telerik ticketing system.

I am sharing the solution here for your fellow developers:

if (maxLengthToBeSet == 4) {
   textBox.get_element().setAttribute('maxLength', 4)
}
 else {
   textBox.get_element().removeAttribute("maxLength");
}