I found this login form on http://codepen.io/suez/pen/dPqxoM, So basically when you click the button it does a ripple effect and what I'm trying to do is adjust the code so that it does the effect only after it has validated that the user exists within the database.
Original Code -
$(document).on("click", ".login_facebook", function(e) {
if (animating) return;
animating = true;
var that = this;
ripple($(that), e);
$(that).addClass("processing");
setTimeout(function() {
$(that).addClass("success");
setTimeout(function() {
window.location = 'home.html';
}, submitPhase2 - 70);
setTimeout(function() {
$login.hide();
$login.addClass("inactive");
animating = false;
$(that).removeClass("success processing");
}, submitPhase2);
}, submitPhase1);
});
My Code Change.
$(document).on("click", ".login__submit", function(e) {
var username = $("#username").val();
var password = $("#password").val();
if( username ==''){
$('.login__row:eq(0)').css("border","2px solid red");
$('.login__row:eq(0)').css("box-shadow","0 0 3px red");
$('.message').show("fast");
}
else
if(password == '')
{
$('.login__row:eq(1)').css("border","2px solid red");
$('.login__row:eq(1)').css("box-shadow","0 0 3px red");
$('.message').show("fast");
}
if(username != "" && password != "")
{
var UrlToPass = 'action=login&username='+username+'&password='+password;
$.ajax({ // Send the credential values to another checker.php using Ajax in POST menthod
type : 'POST',
data : UrlToPass,
url : 'login.php',
success: function(responseText){ // Get the result and asign to each cases
if(responseText == 0){
$('.login__row').css("border","2px solid yellow");
$('.login__row').css("box-shadow","0 0 3px yellow");
}
else if(responseText == 1)
{
if (animating) return;
animating = true;
var that = this;
ripple($(that), e);
$(that).addClass("processing");
setTimeout(function() {
$(that).addClass("success");
setTimeout(function() {
window.location = 'home.html';
}, submitPhase2 - 70);
setTimeout(function() {
$login.hide();
$login.addClass("inactive");
animating = false;
$(that).removeClass("success processing");
}, submitPhase2);
}, submitPhase1);
}
else{
alert('Problem with sql query');
}
}
});
}
});
Thanks in advance