Pages

Sunday, March 25, 2018

How to match password without page refresh or button clicked

In this tutorial i am going to show how to match two passwords without refreshing/ reloading the entire page and even without clicking a button.


Demo:




Installation Proccess:


1: Download Jquery file and 
2: create files given below and paste the code right to them.

File 1.
password match.html

<!doctype html>
<!-- Powered by Computer Master copyright 2018-2030 -->
<html>


<body>
     Password:<br>
<input type="text" id="password1" />
<br><br>
Confirm Password:<br>
<input type="text" id="password2" onfocusout="password_match()" />
 
<!-- The result will show in this div -->
     <div id="show-result">
</div>
      
  <script src="jquery-3.3.1.min.js"></script>
  <script>
  function password_match(){
  var password1 = document.getElementById('password1').value ; 
  var password2 = document.getElementById('password2').value ; 
  
   $.post("check.php", {
  pass1: password1, pass2: password2 
    },
function(data, status){
document.getElementById('show-result').innerHTML = data ; 
}
) ; 
   }
  </script>
  
</body>
</html>



File 2:
check.php

<?PHP

   if(isset($_POST['pass1'])){
   
   if($_POST['pass1'] == $_POST['pass2']){
   echo '<p style="color:green">password matched</p>' ;
   }else{
   echo '<p style="color:red">passwords do not matched</p>'; 
   }
   
    }


 ?>

1 comment: