Irfan Alviansyah Irfan Alviansyah - 1 year ago 101
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


Answer Source

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