Advertisement
Guest User

Untitled

a guest
Apr 30th, 2013
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1.             $('#form-activate').submit(function(event)
  2.             {
  3.                 // Values
  4.                 var mail = $.trim($('#mail').val()),
  5.                     code = $.trim($('#code').val());
  6.  
  7.                 // Check inputs
  8.                 if (code.length === 0)
  9.                 {
  10.                     // Display message
  11.                     displayError('Please fill in activation code');
  12.                     return false;
  13.                 }
  14.                 else if (mail.length === 0)
  15.                 {
  16.                     // Display message
  17.                     formBlock.clearMessages();
  18.                     displayError('Please fill in your email');
  19.                     return false;
  20.                 }
  21.                 else if (!/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(mail))
  22.                 {
  23.                     // Display message
  24.                     formBlock.clearMessages();
  25.                     displayError('Email is not valid');
  26.                     return false;
  27.                 }
  28.                 else
  29.                 {
  30.                     // Remove previous messages
  31.                     formBlock.clearMessages();
  32.  
  33.                     // Show progress
  34.                     displayLoading('Activating...');
  35.                    
  36.                                         // Stop normal behavior
  37.                     event.preventDefault();
  38.  
  39.                                          $.ajax({
  40.                             type: "GET",
  41.                             url: "functions/ajax.php",
  42.                             data: {
  43.                                 func:   "activate",
  44.                                 email: mail,
  45.                                 activation: code
  46.                                     },
  47.    
  48.                             error: function() {
  49.                                 formWrapper.clearMessages();
  50.                                 displayError('Error while contacting server, please try again');
  51.                             },
  52.                             success: function(data) {
  53.                            
  54.                                 if(data == "success") {
  55.                                     formWrapper.clearMessages();
  56.                                     displaySuccess('You can now login to Your account');
  57.                                 } else if(data == "failed") {
  58.                                     formWrapper.clearMessages();
  59.                                     displayError('Invalid code/email, please try again');
  60.                                 } else if(data == "activated") {
  61.                                     formWrapper.clearMessages();
  62.                                     displayError('Account already activated');
  63.                                 }
  64.                             }
  65.                     });
  66.                    
  67.                 }
  68.             });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement