We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to disable/enable TextBox from javascript?


How to disable/enable TextBox control on runtime from javascript?
I have change event applied to DropDownList and want to enable/disable TextBox depends on value from DropDownList.

Code example:

function DropDownListOnChange() {
  var listObj = document.getElementById('drop_down').ej2_instances[0];
  var value = listObj.value;
  var textBoxObj = document.getElementById('text_box').ej2_instances[0];
  if( value == 1) {
    // how to disable TextBox element ???
   textBoxObj.disable(); // <- this don't work
  } else {
   textBoxObj.enable(); // <- this don't work

1 Reply

NP Narayanasamy Panneer Selvam Syncfusion Team October 8, 2019 03:48 AM UTC

Hi Adgr, 
Greetings from Syncfusion support. 
We have validated your requirement and have prepared a sample based on that. We have enabled api for textbox control, based on boolen value we can enable or disable control. In the below sample we have updated value through dropDown control’s value change event. Please find the corresponding code snippet in below, 
            function onValueChange(args) { 
                if (args.value === "disable") { 
                    ejsTextBox.enabled = false; 
                } else { 
                    ejsTextBox.enabled = true; 
Narayanasamy P. 

Live Chat Icon For mobile
Up arrow icon