enable/disble form fields upon radio clicks
Hello,
This is my code. It checks for the radio-status of the field "medewerkers_wachtwoord_wijzigen" and enables/disables 2 other ones upon the status of this field. It does this on pageload and on click a click event.
-
$(document).ready(function(){
jQuery.fn.wwDisable = function() {
this.attr("disabled", true);
};
jQuery.fn.wwEnable = function() {
this.removeAttr("disabled");
};
if($("input[@name='00_settings[medewerkers_wachtwoord_wijzigen]']:checked").val()==0){
$("input[@name='00_settings[wachtwoord_bij_eerste_inlog_wijzigen]']").wwDisable();
$("input[@name='00_settings[geldigheid_wachtwoord]']").wwDisable();
}
$("input[@name='00_settings[medewerkers_wachtwoord_wijzigen]']").click(
function ()
{
if ($(this).val()==0){
$("input[@name='00_settings[wachtwoord_bij_eerste_inlog_wijzigen]']").wwDisable();
$("input[@name='00_settings[geldigheid_wachtwoord]']").wwDisable();
}else{
$("input[@name='00_settings[wachtwoord_bij_eerste_inlog_wijzigen]']").wwEnable();
$("input[@name='00_settings[geldigheid_wachtwoord]']").wwEnable();
}
}
);
});
This works, but somehow the code can be made more efficient I think.
I'm a jquery newbee, can someone give me a hint?