Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax form validation
    primarykey
    data
    text
    <p>I have created an form validation using ajax/php. Each text box is validated using a different file e.g. username_ajax.php. Once the information has been checked to be ok it is then echoed on screen ("Username ok"). I cannot figure out how to allow the user to only press the submit button once all text boxes are 'ok'. Any help will be appreciated, Thanks.</p> <p>My code (Sorry its long): </p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Sign-up&lt;/title&gt; &lt;/head&gt; &lt;script type="text/javascript"&gt; function username(username) { var httpRequest; make_request() function stateck() { if(httpxml.readyState==4) { document.getElementById ("user_div").innerHTML=httpxml.responseText; } } httpxml.onreadystatechange=stateck; user_url="ajax_username.php?username=" + username.value; httpxml.open("GET",user_url,true); httpxml.send(null); } function email(email) { var httpRequest; make_request() function stateck() { if(httpxml.readyState==4) { document.getElementById("email_div").innerHTML=httpxml.responseText; } } httpxml.onreadystatechange=stateck; email_url="ajax_email.php?value=" + email.value; httpxml.open("GET",email_url,true); httpxml.send(null); } function confirm(password,conpassword) { var httpRequest; make_request() function stateck() { if(httpxml.readyState==4) { document.getElementById("conpass_div").innerHTML=httpxml.responseText; } } httpxml.onreadystatechange=stateck; conpassword_url="ajax_password.php?password=" + password.value + "&amp;conpassword=" + conpassword.value; httpxml.open("GET",conpassword_url,true); httpxml.send(null); } &lt;/script&gt; &lt;body&gt; &lt;div id="user_div"&gt;&lt;/div&gt; &lt;div id="conpass_div"&gt;&lt;/div&gt; &lt;div id="email_div"&gt;&lt;/div&gt; &lt;form id="form" name="form" method="post" action=""&gt; &lt;label&gt;Username&lt;br /&gt; &lt;input type="text" name="username" id="username" onBlur="check_username(username)"&gt; &lt;br /&gt; &lt;br /&gt; &lt;/label&gt; &lt;label&gt;Password&lt;br /&gt; &lt;input type="password" name="password" id="password" onBlur="check_confirm (password,conpassword);"&gt; &lt;/label&gt; &lt;label&gt;&lt;br /&gt; &lt;br /&gt; Confirm Password&lt;br /&gt; &lt;input type="password" name="conpassword" id="conpassword" onBlur="check_confirm(password,conpassword);"&gt; &lt;br /&gt; &lt;br /&gt; &lt;/label&gt; &lt;label&gt;Email&lt;br /&gt; &lt;input type="text" name="email" id="email" onblur="check_email(email)" /&gt; &lt;p&gt; &lt;p&gt; &lt;label&gt; &lt;input type="submit" name="button" id="button" value="Submit" onclick="return false;" /&gt; &lt;/label&gt; &lt;/p&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    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