How to check textbox is readonly using jQuery

Previously I had posted about "How to make textbox readonly using jQuery". One of way is to make textbox readonly is to set "readonly" attribute to true. So use the same attribute "readonly" to find out whether textbox is readonly or not using jQuery.

$(document).ready(function(){
    $("#txtReadonly").attr('readonly', true);
    var isReadonly = $("#txtReadonly").attr('readonly');
    alert('txtReadonly is not readonly ' + isReadonly);
    var isNotReadonly = $("#txtNotReadonly").attr('readonly');
    alert('txtNotReadonly is not readonly ' + isNotReadonly);
});
See live Demo and Code.

Feel free to contact me for any help related to jQuery, I will gladly help you.



Responsive Menu
Add more content here...