Irfan Alviansyah Irfan Alviansyah - 10 months ago 51
Ajax Question

How to Disable input text on form?

I want to disable and enable input text if action add input text enable And if action edit input text disable



You can achieve this using the jQuery function prop() :


var value = $('input').val();

if (value == null) {
   $("input").prop('disabled', false);
} else {
   $("input").prop('disabled', true);

Here is a demo: JsFiddle