css - How to remove attribute "readonly" Using JQuery -
i'm implementing bulletin free board pages applied secret , non-secret board's page password number.
i want implement if checkbox distinguish whether writings secret checked, want remove readonly attribute of password applying secret bulletin.
the password's id = bbs_password
the checkbox id = secret_yn
because of source privacy, can't attach on directly. please understand me.
alternately, attach part of sourced codes photo.
this have far :
$(document).ready(function(){ $('#bbs_password').attr('readonly','readonly') if($('input:checkbox[id="secret_yn"]').is(":checked") == true){ $('#bbs_password').removeattr('readonly','readonly'); if(document.bbs_write_form.bbs_password.value == ""){ alert("input password!); document.bbs_write_form.bbs_password.focus(); return false; } }
to set element read-only:
$('#bbs_password').prop('readonly', true);
and switch editable:
$('#bbs_password').prop('readonly', false);
if have jquery version older 1.9, need use instead:
$('#bbs_password').attr('readonly', true);
Comments
Post a Comment