I have written a simple function that validates a form based on the form
objects' className attribute. The form basically write a "field
required" message next to the form element that is blank(and is
required). I have implemented all the Regex stuff onload already.
function checkRequired(v arForm){
var varReturn = true;
for(var i=0; i<varForm.lengt h; i++){
if(varForm.elem ents[i].className.inde xOf('required') != -1 &&\
varForm.element s[i].value == ""){
varSpan=documen t.createElement ('span');
varMsg=document .createTextNode ('* This field is required!');
varSpan.appendC hild(varMsg);
varSpan.setAttr ibute("class", "error");
varForm.element s[i].parentNode.app endChild(varSpa n);
varReturn = false;
}
}
return varReturn;
}
I am having difficulty removing the new nodes I have created. Each time
I click submit, I want the nodes I created to be removed, otherwise I
just keep on appending the same message string each time. Any suggestions?
objects' className attribute. The form basically write a "field
required" message next to the form element that is blank(and is
required). I have implemented all the Regex stuff onload already.
function checkRequired(v arForm){
var varReturn = true;
for(var i=0; i<varForm.lengt h; i++){
if(varForm.elem ents[i].className.inde xOf('required') != -1 &&\
varForm.element s[i].value == ""){
varSpan=documen t.createElement ('span');
varMsg=document .createTextNode ('* This field is required!');
varSpan.appendC hild(varMsg);
varSpan.setAttr ibute("class", "error");
varForm.element s[i].parentNode.app endChild(varSpa n);
varReturn = false;
}
}
return varReturn;
}
I am having difficulty removing the new nodes I have created. Each time
I click submit, I want the nodes I created to be removed, otherwise I
just keep on appending the same message string each time. Any suggestions?
Comment