input type text disabled – How to disable an input type=text?

input type text disabled – This article will discuss how to disable and enable an input text box Example using jQuery/javaScript.

input type text disabled

we get to know how to disable an input type=text by using the input disabled attribute. To disable an input element, its disabled HTML attribute should be false.

document.getElementById('registrationname').disabled = true;

//OR

document.getElementById('registrationname').readOnly = true;

Disable and enable an input text box with JavaScript/jQuery

$(document).ready(function() {
    var disabled = false;
    $('#signup').click(function() {
        if (disabled) {
            $("#registrationname").prop('disabled', false);       // if disabled, enable
        }
        else {
            $("#registrationname").prop('disabled', true);        // if enabled, disable
        }
        disabled = !disabled;
    })
});

Example


//or...

using jQuery

$('#registrationname')[0].disabled = true;

//OR


Don’t Miss : HTML DOM Input Text Disabled/Enable Property

I hope you get an idea about input type text disabled.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment