r41488 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41487‎ | r41488 | r41489 >
Date:15:33, 1 October 2008
Author:yaron
Status:old
Tags:
Comment:
Added validate_mandatory_checkboxes() Javascript function
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.inc
@@ -87,6 +87,25 @@
8888 }
8989 }
9090
 91+function validate_mandatory_checkboxes(field_id, info_id) {
 92+ elems = document.getElementsByTagName("*");
 93+ var all_fields_unchecked = true;
 94+ for (var i = 0; i < elems.length; i++) {
 95+ if (elems[i].id == field_id) {
 96+ if (elems[i].checked) {
 97+ all_fields_unchecked = false;
 98+ }
 99+ }
 100+ }
 101+ if (all_fields_unchecked) {
 102+ infobox = document.getElementById(info_id);
 103+ infobox.innerHTML = "$blank_error_str";
 104+ return false;
 105+ } else {
 106+ return true;
 107+ }
 108+}
 109+
91110 // validate a mandatory field that exists across multiple instances of
92111 // a template - we have to find each one, matching on the pattern of its
93112 // ID, and validate it

Status & tagging log