Irfan Alviansyah Irfan Alviansyah - 6 months ago 21
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

thanks

Answer

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

Javscript

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

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

Here is a demo: JsFiddle

Comments