jQuery javascript make an input readonly

To make an input readonly, simply use .prop

	$("#fieldName").prop("readonly", true);
	//or
	$("#fieldName").attr('readonly','readonly');

To enable the input

	$("#fieldName").prop("readonly", false);
	//or
	$("#fieldName").removeAttr('readonly');

By Keenlio, May 9, 2014

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *


8 × seven =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>