How can I get my validate function to be translated into a Ajax server call?

Hello Everyone,

How can I validate each of (upper textboxes) using AJAX to see if the username and password is correct and if they are not correct, display the error messages in red below each respective textbox. Here is my code. Any suggestions would be help. I know I could use the $.ajax() method, but I don’t know how I can translate my current validate function into the sensible ajax method. Any help would be much appreciated, and how I can implement animate method into this ajax method. Can someone please help me?

<html>

<head>

  <link href="Home.css" rel="stylesheet" />
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <title>Project</title>

</head>

<body>


<div class="container">
  <div class="intro">

    <h1>Welcome to Cuyahoga Community College Student Services Online</h1>

    <p>Cuyahoga Community College recognizes students' rights to access personal and academic records in accordance with the Family Educational Rights and Privacy Act of 1974 (FERPA) as amended by Public Law 93-568.</p>
  </div>
  <br/>

  <div class="content">
    <div class="row top">
      <p id="para1">Already have an account with us? Returning users may log in by entering their site username and password. </p>
      <div class="login">
        <label class="username-label" for="username-part1">Username</label> 
         <input class="existing1-username-input-textbox" type="text" value=""> 
         <span id="username_error1">*</span><br><br>

        <label class="password-label" for="password-part2">Password</label>
        <input class="existing2-password-input-textbox" type="password" value="">
        <span id="password_error2">*</span><br>
        <button id="button1">Log in</button>
      </div>
    </div>
    <hr/>
    <div class="row bottom">
      <p id="para2">New users, please create a new account by providing us with some basic information.</p>

      <div class= "new_customers_info">

        <label class="Username-label1" for="new-user-name-part-1">Username</label>
        <input class="username-new-input-textbox" type="text" value="">
         <br/><br/>

        <label class="Password-label2" for="password-new-part2">Password</label>
        <input class="password-new-input-textbox" type="password" value="">
         <br/><br/>

        <label class="Email-label3" for="email-new">Email Address</label>
         <input class="email-new-input-textbox" type="email" value="" >
          <br/><br/>

        <label class="Repeat-Email-label4" for="repeat-new-email">Repeat Email Address</label>
         <input class="reenter-new-input-textbox" type="email" value="">

        <button id="button2">Create Account</button>
      </div>
    </div>
  </div>
   <br/>
  <footer>Cuyahoga Community College</footer>
  <footer>700 Carnegie Avenue, Cleveland, Ohio, 44115</footer>
</div>
    <script src="Home.js"></script>
</body>
</html>
.intro h1 {
  font-family: 'Cambria';
  font-size: 16pt;
  font: bold;
  text-align: left;
}

.intro p {
  font-family: 'Calibri';
  font: italic;
  font-size: 12pt;
  padding: 0px 690px 0px 20px;
  text-align: left;
}

.content {
  border: 2px solid;
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  border-radius: 10px;
}

#para1 {
  padding: 0px 1050px 0px 20px;
}

#para2 {
  padding: 0px 1099px 0px 20px;
}

.username-label,
.password-label {
 margin: 10px 0px 0px 300px;
 position: relative; 
 top: -70px; 
}

.existing1-username-input-textbox, 
.existing2-password-input-textbox
{
    top: -70px; 
     position: relative; 
      
}

#button1{ 
     background-color: #add8e6;
     margin-left: 390px; 
     position: relative; 
     top: -50px; 
    -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  border-radius:10px;
  padding: 0px 20px 0px 20px; 
}

#button2{
  background-color: #add8e6;
  margin-left: -200px; 
  position: relative; 
  top: -30px; 
 -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  border-radius: 10px;
  padding: 0px 20px 0px 20px; 

}


.Username-label1, 
.Password-label2,           
.Email-label3, 
.Repeat-Email-label4 
{
  margin: 0px 0px 0px 300px;
  position: relative; 
  top: -70px; 
}
.username-new-input-textbox, 
.password-new-input-textbox, 
.email-new-input-textbox, 
.reenter-new-input-textbox{ 
  position: relative;
   top: -70px;
  margin-left: 20px; 

} 

span{
  
 color: red; 
}

document.getElementById("button1").addEventListener("click", mouseOver1);

function mouseOver1(){

   document.getElementById("button1").style.color = "red";

}


document.getElementById("button2").addEventListener("click", mouseOver); 


    function mouseOver(){ 

      document.getElementById("button2").style.color = "purple";
   }



$("#button1").hover(function() {
    $(this).css('cursor','pointer');
}); 

$("#button2").hover(function() {
    $(this).css('cursor','pointer');
}); 
 
$(document).ready(function(){

   $(".login").validate({
     rules:{
        existing1-username-input-textbox: "reqiured", 
        existing2-password-input-textbox: "reqiured", 
          
         existing1-username-input-textbox:{
            required: true, 
            minlength: 10,
            equalTo: "S01029575"
  
        }, 
        existing2-password-input-textbox:{
          required: true, 
          minlength: 10', 
          equalTo: "honor7thG" 
       }, 
       messages: {
         existing1-username-input-textbox: {
           required: "You must enter a valid existing user account.", 
           minlength: "Your username must be at least 10 characters long."
          }, 
          existing2-password-input-textbox: {
           required: "You must enter a valid password associated with an account.", 
           minlength: "Your username must be at least 10 characters long."
          }
      }); 

      // Here is animate method I am want to implement if the username and password is 
    // correct.

    $('#para1').animate({
      'left': '-500%'
    });
    $('.username-label').animate({
      'left': '-105%'
    });
    $('.existing1-username-input-textbox').animate({
      'left': '-105%'
    });
    $('.password-label').animate({
      'left': '-105%'
    });
    $('.existing2-password-input-textbox').animate({
      'left': '-105%'
    });
    $('#button1').animate({
      'left': '-105%'
    });
  }
});

   
      
         
        

      


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.