michael@0: /* michael@0: * $_ michael@0: * michael@0: * Returns the element with the specified |name| attribute. michael@0: */ michael@0: function $_(formNum, name) { michael@0: var form = document.getElementById("form" + formNum); michael@0: if (!form) { michael@0: logWarning("$_ couldn't find requested form " + formNum); michael@0: return null; michael@0: } michael@0: michael@0: var element = form.elements.namedItem(name); michael@0: if (!element) { michael@0: logWarning("$_ couldn't find requested element " + name); michael@0: return null; michael@0: } michael@0: michael@0: // Note that namedItem is a bit stupid, and will prefer an michael@0: // |id| attribute over a |name| attribute when looking for michael@0: // the element. Login Mananger happens to use .namedItem michael@0: // anyway, but let's rigorously check it here anyway so michael@0: // that we don't end up with tests that mistakenly pass. michael@0: michael@0: if (element.getAttribute("name") != name) { michael@0: logWarning("$_ got confused."); michael@0: return null; michael@0: } michael@0: michael@0: return element; michael@0: } michael@0: michael@0: michael@0: /* michael@0: * checkForm michael@0: * michael@0: * Check a form for expected values. If an argument is null, a field's michael@0: * expected value will be the default value. michael@0: * michael@0: *