Note that there are some explanatory texts on larger screens.

plurals
  1. POform validation in php/ajax
    primarykey
    data
    text
    <p>i was trying to add an exception like if user input nothing or input wrong 'Contact ID' and press enter, an error message will come out &amp; notifying user that ID not found. any help? thanks in advance:) here is my index.html file.</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;script language="javascript" type="text/javascript"&gt; function ajaxFunction(e){ var e=e || window.event; var keycode=e.which || e.keyCode; if(keycode==13 || (e.target||e.srcElement).value==''){ var http; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari http = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ http = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ http = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } var url = "getagentids.php?param="; var idValue = document.getElementById("agid").value; var myRandom = parseInt(Math.random()*99999999); // cache buster http.open("GET", "getagentids.php?param=" + escape(idValue) + "&amp;rand=" + myRandom, true); http.onreadystatechange = handleHttpResponse; http.send(null); function handleHttpResponse() { if (http.readyState == 4) { results = http.responseText.split(","); document.getElementById('agfn').value = results[0]; document.getElementById('agsal').value = results[1]; document.getElementById('agtel').value = results[2]; document.getElementById('agid').value = results[3]; } } } } &lt;/script&gt; &lt;form&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Contact ID:&lt;/td&gt; &lt;td&gt;&lt;input id="agid" type="text" name="contactid" onkeyup="ajaxFunction(event)"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Tel Number:&lt;/td&gt; &lt;td&gt;&lt;input id="agtel" type="text" name="contacttel"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Name:&lt;/td&gt; &lt;td&gt;&lt;input id="agfn" type="text" name="contactfullname"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Salutation:&lt;/td&gt; &lt;td&gt;&lt;input id="agsal" type="text" name="contactsalutation"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="reset" value="Clear"&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    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.
 

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