Note that there are some explanatory texts on larger screens.

plurals
  1. POForm Validation Help
    text
    copied!<p>Hi I'm trying to create a simple registration form with ajax validation. I've got the form working almost how I'd like... a message appears on the page with the errors for each field entered incorrectly. </p> <p>The problem is all the error messages appear in one div together and I would like to have each field have its own div containing only its own error. </p> <p>I think I need to wrap my error messages in xml and use something like this - </p> <pre><code>document.getElementById("feedback1").innerHTML= xmlDoc.getElementsByTagName("lname")[0].childNodes[0].nodeValue; </code></pre> <p>- but can't seem to get it working</p> <p>Does anyone know how I should modify my code to do this? </p> <p>Here is my source containing the 3 file I'm currently using - <a href="http://www.cultivatedesigns.ca/Uploads/ajax-validation.zip" rel="nofollow noreferrer">http://www.cultivatedesigns.ca/Uploads/ajax-validation.zip</a></p> <p>And Here is my code for my ajax page only.</p> <pre><code> var xmlHttp; function regForm(thisform) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return; } var formdata = ""; formdata = "lname=" + thisform.elements['lname'].value + "&amp;fname=" + thisform.elements['fname'].value + "&amp;email=" + thisform.elements['email'].value + "&amp;username=" + thisform.elements['username'].value + "&amp;pass=" + thisform.elements['pass'].value + "&amp;pass2=" + thisform.elements['pass2'].value; xmlHttp.onreadystatechange=formSubmitted; xmlHttp.open("POST", "adduser.php",true); xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xmlHttp.setRequestHeader("Content-length", formdata.length); xmlHttp.setRequestHeader("Connection", "close"); xmlHttp.send(formdata); return false; } function formSubmitted() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { xmlDoc=xmlHttp.responseXML; document.getElementById("feedback").innerHTML = xmlHttp.responseText; //document.getElementById("feedback1").innerHTML= xmlDoc.getElementsByTagName("lname")[0].childNodes[0].nodeValue; } } function GetXmlHttpObject() { xmlHttp=null; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } </code></pre> <p>Thanks for any help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload