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;     } } 

enter image description here enter image description here very reading this.

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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -