Set the read-only TextBox

17 Feb 20222 minutes to read

You can make the TextBox as read-only by setting the readonly attribute to the input element.

<div class="control-section">
    <div class="control_wrapper accordion-control-section">
        <input class="e-input" type="text" placeholder="Enter Name" value="John" readonly />

        <div class="e-float-input">
            <input type='text' required readonly value="John" />
            <span class="e-float-line"></span>
            <label class="e-float-text e-label-top">Enter Name</label>
        </div>
    </div>
</div>
<script>
    ej.base.enableRipple(true);

    // To get the all input fields and its container.

    var inputElement = document.querySelectorAll('.e-input-group .e-input,.e-float-input.e-input-group input');

    // Add 'e-input-focus' class to the input for achive ripple effect when focus on the input field.

    for (var i = 0; i < inputElement.length; i++) {
        inputElement[i].addEventListener('focus', function () {
            this.parentNode.classList.add('e-input-focus');
        });
        inputElement[i].addEventListener('blur', function () {
            this.parentNode.classList.remove('e-input-focus');
        });
    }

</script>
public ActionResult Index()
{
    return View();
}