Readonly or disable input box using jquery onClick
In this tutorial I will be helpful for you to disabled or read only input box by clicking a button or change some value of a input box using jQuery.
Using jQuery you can add different thoughts and make your webpage modern. jQuery work in a website very quickly and return value so fast and it’s use so easy in a web page.
This tutorial I will give two type of example of disable or read only text field using jQuery. Follow the example:
Click button disabled or read only input box:
$('#button_id').on("click", function(){ $('#text_id').attr('disabled',true); $('#text_id').attr('readonly',true); });
In your webpage Using attr(), you can set disabled or readonly attribute in you a input box of a webpage.
Change value disabled or read only input box:
$('#price').on("keypress keyup blur paste", function(){ var price1 = $('#price1').val(); var price1 = $('#price2').val(); var totalprice = parseFloat(price1) + parseFloat(price2); $('#totalvalue').val(totalprice).attr('disabled',true); $('#totalvalue').val(totalprice).attr('readonly',true); });
This example help you, when you change a input field price value and set calculate value in a input box, then input box show disabled or readonly using this code.