amatsoukas
05-29-2012, 03:03 PM
Hi everyone.
I'm a little bit of a newbie here, so if you could please either help me answer this problem or point me somehwere where I might find the answer it would be greatly appreciated.
I have an online form that has some (external) Javascript validation attached to it. I want to store the error messages in an external xml file and call them during the validation.
Here is a sample of my xml file structure:
<Webform_Error_Messages>
<blank_first_name>You must enter your first name.</blank_first_name>
</Webform_Error_Messages>
Now, the reason I'm posting this here is that I believe my issue is in the Javascript integration. On form submit, the validate_webform function gets executed.
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET","dname",false);
xhttp.send();
return xhttp.responseXML;
}
function validate_webform(thisform)
{
xmlDoc=loadXMLDoc("webform_error_msgs_en.xml");
with (thisform)
{
if (validate_required(first_name)==false)
{
first_name_error.innerHTML = xmlDoc.getElementsByTagName("blank_first_name")[0].childNodes[0].nodeValue;
return false;
}
}
}
What happens when I click submit is that the form goes ahead and submits, foregoing all validation. When I replace my xml error messages with a regular text string (i.e. first_name_error.innerHTML = "this is an error"), everything works great.
I have also validated my xml document to ensure there are no errors in it.
I realize that it may be a seemingly easy answer or a very obvious solution to some, but I've been searching for a solution going on 3 days now to no avail, so any help as to why this is not working would be greatly appreciated.
Thank you for your time.
I'm a little bit of a newbie here, so if you could please either help me answer this problem or point me somehwere where I might find the answer it would be greatly appreciated.
I have an online form that has some (external) Javascript validation attached to it. I want to store the error messages in an external xml file and call them during the validation.
Here is a sample of my xml file structure:
<Webform_Error_Messages>
<blank_first_name>You must enter your first name.</blank_first_name>
</Webform_Error_Messages>
Now, the reason I'm posting this here is that I believe my issue is in the Javascript integration. On form submit, the validate_webform function gets executed.
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET","dname",false);
xhttp.send();
return xhttp.responseXML;
}
function validate_webform(thisform)
{
xmlDoc=loadXMLDoc("webform_error_msgs_en.xml");
with (thisform)
{
if (validate_required(first_name)==false)
{
first_name_error.innerHTML = xmlDoc.getElementsByTagName("blank_first_name")[0].childNodes[0].nodeValue;
return false;
}
}
}
What happens when I click submit is that the form goes ahead and submits, foregoing all validation. When I replace my xml error messages with a regular text string (i.e. first_name_error.innerHTML = "this is an error"), everything works great.
I have also validated my xml document to ensure there are no errors in it.
I realize that it may be a seemingly easy answer or a very obvious solution to some, but I've been searching for a solution going on 3 days now to no avail, so any help as to why this is not working would be greatly appreciated.
Thank you for your time.