javascript - How can I validate multiply input values at the same time using onkeyup before activating the submit button? -


i want create form submit button disabled until form ready submitted. not form need filled in, parameters need met. passwords must match. email must valid , not in database. radio button must selected. how can send values inputs @ same time on every upkey.

here's index.php file

<html> <head>     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>     <script type="text/javascript">         function validate_form(value){             $.post("validate_form.php",{first_name:value},function(data){                 if (data=="available"){                     document.getelementbyid("mysubmit").disabled = false;                 } else {                     document.getelementbyid("mysubmit").disabled = true;                 }             });         };      </script> </head> <body>     <form action="index.php" method="post">         <input type="text" name="first_name" placeholder="first name" onkeyup="validate_form(first_name.value)"><br>         <input type="text" name="last_name" placeholder="last name"><br>         <input type="text" name="email" placeholder="email"><br>         <input type="password" name="password" placeholder="password"><br>         <input type="password" name="password_repeat" placeholder="re-enter password"><br>         <input type="radio" name="choice" value="y" id="yes">yes         <input type="radio" name="choice" value="n" id="no">no         <br>         <input type="submit" name="submit" value="sign up" disabled id="mysubmit">     </form> </body> </html> 

and here's validate_form.php file

<?php      $first_name = "";     $last_name = "";     $email = "";     $password = "";     $password_repeat = "";     $answer = "";     $go = array(0,0,0,0,0);      if(isset($_post['first_name'])){$first_name = $_post['first_name'];}     if(isset($_post['last_name'])){$last_name = $_post['last_name'];}     if(isset($_post['email'])){$email = $_post['email'];}     if(isset($_post['password'])){$password = $_post['password'];}     if(isset($_post['password_repeat'])){$password_repeat = $_post['password_repeat'];}     if(isset($_post['choice'])){$answer = $_post['answer'];}          //does email exist in database     mysql_connect("localhost", "root", "password") or die (mysql_error ());     mysql_select_db("database") or die(mysql_error());     $strsql = "select * users";     $loop = mysql_query($strsql);        $email_exists = 0;     while($row = mysql_fetch_array($loop)) {         if($row['email'] == $email){             $email_exists = 1;         }     }      //is email valid      if (!filter_var($email, filter_validate_email) === false) {         $email_valid = 1;     } else {         $email_valid = 0;     }      //check each parameter      if(strlen($first_name) > 0){         $go[0] = 1;     }     if(strlen($last_name) > 0){         $go[1] = 1;     }     if($email_exists != 1 , $email_valid == 1){         $go[2] = 1;     }     if(strlen($password) > 6 , $password == $password_repeat){         $go[3] = 1;     }     if($answer != ""){         $go[4] = 1;     }      if(array_sum($go) == 5){         echo "available";     } else {         echo "form not viable";     }   ?> 

i have send $first_name validate_form.php, i'm not sure how send variables @ once. awesome.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -