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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to disable/enable TextBox from javascript?

Thread ID:

Created:

Updated:

Platform:

Replies:

148088 Oct 4,2019 03:13 PM UTC Oct 8,2019 03:48 AM UTC ASP.NET Core - EJ 2 1
loading
Tags: Text Box
adgr
Asked On October 4, 2019 03:13 PM UTC

Hi,

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
  }
}


Narayanasamy Panneer Selvam [Syncfusion]
Replied On 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; 
                } 
            } 
 
 
Regards, 
Narayanasamy P. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon