Using .NET MVC3 and Jquery, I have a checkbox toggling whether an input box is readonly or not. However, when it is set to a readonly mode, it passes the value of the field as null to controller. My Jquery code is below:
$(document).ready(function () {
if ($(this).attr('checked')) {
$(":text").attr('readonly', true);
$(":checkbox").not(this).attr('readonly', true);
} else {
$(":text").attr('readonly', false);
$(":checkbox").not(this).attr('readonly', false);
}
});
Any ideas?
try like this
javascript code :
demo : JsFiddle