Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax Form Validation Problem
    primarykey
    data
    text
    <p>I've got my form validation almost working but I can't seem to figure this last problem out.</p> <p>I'm trying to send back error messages and position them in their own div next to their relevant form fields.</p> <p>I've got an error message coming back in its own div, but when I try to send multiple messages back nothing happens, any thoughts?</p> <p>Here's most of my ajax</p> <pre><code>function regForm(thisform) { //Reg user form check 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; //send the data through the url - frist is the name i want to call it... second grad the content from the form using its id 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; document.getElementById("feedback2").innerHTML= xmlDoc.getElementsByTagName("fname")[0].childNodes[0].nodeValue; } } </code></pre> <p>and here is my simple adduser.php page so far</p> <pre><code>&lt;?php header('Content-Type: text/xml'); $lname = mysql_real_escape_string($_POST['lname']); $fname = mysql_real_escape_string($_POST['fname']); if($lname == NULL) { echo "&lt;lname&gt;NEED TO FILL&lt;/lname&gt;"; } //if($fname == NULL) { //echo "&lt;fname&gt;NEED TO FILL&lt;/fname&gt;"; //} else { echo "&lt;lname&gt; &lt;/lname&gt;"; //echo "&lt;fname&gt; &lt;/fname&gt;"; } ?&gt; </code></pre> <p>As you can see I've got the fname information commented out right now and my messaging is working for lname but as soon as I uncomment the fname stuff in hopes to send a message for both lname and fname nothing happens I don't understand why.</p> <p>Any insight would be a big help! Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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