Flagging of invalid Survey fields now uses CSS classes instead of <font> tags

(for skinnability)
This commit is contained in:
Patrick Donelan 2008-12-04 03:37:59 +00:00
parent 5083085abb
commit ec674dd5f4
2 changed files with 19 additions and 3 deletions

View file

@ -4,7 +4,10 @@ if (typeof Survey === "undefined") {
}
(function(){
var CLASS_INVALID = 'survey-invalid'; // For elements that fail input validation
var CLASS_INVALID_MARKER = 'survey-invalid-marker'; // For default '*' invalid field marker
var multipleChoice = {
'Multiple Choice': 1,
'Gender': 1,
@ -90,12 +93,20 @@ if (typeof Survey === "undefined") {
}
}
}
var node = document.getElementById(i + 'required');
var q_parent_node = YAHOO.util.Dom.getAncestorByClassName(node, 'question');
if (!answered) {
submit = 0;
document.getElementById(i + 'required').innerHTML = "<font color=red>*</font>";
// Apply CLASS_INVALID to the parent question div for people who want to skin Survey
YAHOO.util.Dom.addClass(q_parent_node, CLASS_INVALID);
// Insert default '*' marker (can be hidden via CSS for those who want something different)
node.innerHTML = "<span class='" + CLASS_INVALID_MARKER + "'>*</span>";
}
else {
document.getElementById(i + 'required').innerHTML = "";
YAHOO.util.Dom.removeClass(q_parent_node, CLASS_INVALID);
node.innerHTML = '';
}
}
}

View file

@ -83,3 +83,8 @@ input.mcbutton-selected{
background-image: url(/extras/wobject/Survey/gradient-glossy.png);
background-position: 0px 0px;
}
/* By default the marker for invalid (required) fields is a red '*' */
.survey-invalid-marker {
color: #FF0000;
}