Advertisement
dsull290

Untitled

May 25th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 2.58 KB | None | 0 0
  1. $(document).ready(function() {
  2.     $('[data-toggle="tooltip"]').tooltip();
  3.     $('input[type="submit"]').attr("disabled","disabled");
  4.     $('#reg-user').blur(function() {
  5.         var regex_USER = /^[a-zA-Z0-9._-]+$/i;
  6.         var user = $(this).val();
  7.         $.post('exe/run_user_check.php', {reg_user: $('#reg-user').val()}, function(data) {
  8.                 alert(data);
  9.         }, 'text');
  10.         if (regex_USER.test(user) === false) {
  11.             $('#reg-user').css({
  12.                 "box-shadow": "0 0 5px red",
  13.                 "border": "1px solid red"
  14.             });
  15.         }else{
  16.             $('#reg-user').css({
  17.                 "box-shadow": "0 0 5px green",
  18.                 "border": "1px solid green"
  19.             });
  20.         }
  21.         if (user === "") {
  22.             $(this).removeAttr("style");
  23.         }
  24.     });
  25.     $('#reg-pass').blur(function() {
  26.         var pass = $(this).val();
  27.         if (pass.length < 6) {
  28.             $('#reg-pass').css({
  29.                 "box-shadow": "0 0 5px red",
  30.                 "border": "1px solid red"
  31.             });
  32.         }else{
  33.             $('#reg-pass').css({
  34.                 "box-shadow": "0 0 5px green",
  35.                 "border": "1px solid green"
  36.             });
  37.         }
  38.         if (pass === "") {
  39.             $(this).removeAttr("style");
  40.         }
  41.     });
  42.     $('#reg-pass2').blur(function() {
  43.         var pass2 = $(this).val();
  44.         if (pass2 !== $('#reg-pass').val()) {
  45.             $('#reg-pass2').css({
  46.                 "box-shadow": "0 0 5px red",
  47.                 "border": "1px solid red"
  48.             });
  49.         }else{
  50.             $('#reg-pass2').css({
  51.                 "box-shadow": "0 0 5px green",
  52.                 "border": "1px solid green"
  53.             });
  54.         }
  55.         if (pass2 === "") {
  56.             $(this).removeAttr("style");
  57.         }
  58.     });
  59.     $('#reg-email').blur(function() {
  60.         var regexEmail = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]+$/i;
  61.         var regEmail = $(this).val();
  62.         if (regexEmail.test(regEmail) === false) {
  63.             $('#reg-email').css({
  64.                 "box-shadow": "0 0 5px red",
  65.                 "border": "1px solid red"
  66.             });
  67.         }else{
  68.             $('#reg-email').css({
  69.                 "box-shadow": "0 0 5px green",
  70.                 "border": "1px solid green"
  71.             });
  72.         }
  73.         if (regEmail === "") {
  74.             $(this).removeAttr("style");
  75.         }
  76.     });
  77.     $('#agree').click(function() {
  78.         $('input[type="submit"]').attr("disabled", !this.checked);
  79.     });
  80.     $('.reg-form').submit(function(e) {
  81.         var dataString = $(this).serialize();
  82.         $.ajax({
  83.             url: 'exe/process_reg.php',
  84.             dataType: 'text',
  85.             type: 'post',
  86.             contentType: 'application/x-www-form-urlencoded',
  87.             data: dataString,
  88.             success: function(data) {
  89.                 $('.reg-form').hide();
  90.                 $('body').append('<div class="alert alert-success m-auto" role="alert">Your registeration has been submitted successfully.<br /><a href="login.php" class="alert-link">Login to Account</a><br>'+data+'</div>');
  91.                 $('input').removeAttr("style");
  92.                 $('.reg-form')[0].reset();
  93.             }
  94.         });
  95.         e.preventDefault();
  96.     });
  97. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement