Is it possible to retrieve a label from a form? I would like to retrieve the LABEL and parrot it back within the error message without having to hard code it. Here is part of the current form and javascript. Thanks in advance for any asistance.
<form method=”get” name=”addissue” onsubmit=”return validate(this)”>
<LABEL>Effective: </LABEL><input type=”date” name=”effDate” readonly size=”10″ border=”0″></div>
<input type=”submit” name=”submitButtonName” value=”Add” border=”0″>
<div ID=”error” align=”left”>
function validate(thisForm) {
// Loop through form elements
for (counter2 = 0; counter2 < thisForm.elements.length; counter2++)
{
var e=thisForm.elements[counter2].name;
var fieldtype=thisForm.elements[counter2].type;
// If blank
if (thisForm.elements[counter2].value == “”)
errormsg += thisForm.elements[counter2].name +” is blank.<br>”;
fixThis(thisForm, errormsg);
…
}
function fixThis(thisForm, msg) {
error.innerHTML=msg;
error.style.color=”Red”;
}