I have a bunch of <input type="text">, <textarea> and <select> tags which if they have a value already I can stop them being edited. However, how do I stop changes to radio buttons and checkboxes? It's almost as if I need to say I have finished initially setting them, so if I try to get focus I can stop it. Not sure how to do this going from one radio button/checkbox to another the focus will be lost and re-gained, whcih is value until I have finished with them. Any ideas?
Here is my code ...
//Stop elements gaining access if they already have a value
$("input, textarea, select").focus(function(e) {
e.preventDefault();
var t = $(this).attr("type");
switch (t) {
case "radio" :
break;
case "checkbox" :
break;
case "select-one" :
if ($(this).val() != "") {$(this).blur();}
break;
case "text" :
if ($(this).val() != "") {$(this).blur();}
break;
case "textarea" :
if ($(this).val() != "") {$(this).blur();}
break;
}
});
//Stop double click gaining access to the <select> tag. Without this double click still gains access!
$("#questionnaire select").dblclick(function(e) {
e.preventDefault();
if ($(this).val() != "") {$(this).blur(); alert(objSettings.msg.changesurveyanswer);}
});