Advertisement
Guest User

Untitled

a guest
Mar 11th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function validateSignup() {
  2.    
  3.     var username = document.forms["signup_form"]["username"].value;
  4.     var pass = document.forms["signup_form"]["password"].value;
  5.     var confirm_pass = document.forms["signup_form"]["confirm_password"].value;
  6.     var email = document.forms["signup_form"]["email"].value;
  7.    
  8.     if(username == "" || pass == "" || confirm_pass == "" || email == "") {
  9.         $("#signup_error").attr("class", "alert alert-danger");
  10.         $("#signup_error").html("All details required. Please fill in all fields.");
  11.         return false;
  12.     } else if(pass != confirm_pass) {
  13.         $("#signup_error").attr("class", "alert alert-danger");
  14.         $("#signup_error").html("Passwords doesn't match.");
  15.         return false;
  16.     }
  17.     else {
  18.         $.ajax({
  19.             url: "authentication.php",
  20.             type: "POST",
  21.             data: { "username" : username, "password" : pass, "email" : email, "subscription" : subscription, "method" : "register"},
  22.             success: function(data){
  23.                 console.log(data);
  24.                 if(data == true) {
  25.                     var count = 3;
  26.                     $("#signup_error").attr("class", "alert alert-success");
  27.                     $("#signup_error").html("<i class='fa fa-check'></i> Registration successful! Please confirm your e-mail address in order to make your account active. Redirecting in <div id='timer' style='display: inline'></div>");
  28.                     document.getElementById('timer').innerHTML = count;
  29.                     setInterval(function(){
  30.                         count--;
  31.                         document.getElementById('timer').innerHTML = count;
  32.                         if (count == 0) {
  33.                             window.location = 'http://ghostbg.interdevice.club/';
  34.                         }
  35.                     },1000);
  36.                     return false;
  37.                 } else {
  38.                     $("#signup_error").attr("class", "alert alert-danger");
  39.                     $("#signup_error").html("<i class='fa fa-ban'></i> Account with that username/email already exist.");
  40.                     return false;
  41.                 }
  42.             }
  43.         });
  44.         return false;
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement