Irfan Alviansyah Irfan Alviansyah - 2 years ago 146
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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download