Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('#form-activate').submit(function(event)
- {
- // Values
- var mail = $.trim($('#mail').val()),
- code = $.trim($('#code').val());
- // Check inputs
- if (code.length === 0)
- {
- // Display message
- displayError('Please fill in activation code');
- return false;
- }
- else if (mail.length === 0)
- {
- // Display message
- formBlock.clearMessages();
- displayError('Please fill in your email');
- return false;
- }
- 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))
- {
- // Display message
- formBlock.clearMessages();
- displayError('Email is not valid');
- return false;
- }
- else
- {
- // Remove previous messages
- formBlock.clearMessages();
- // Show progress
- displayLoading('Activating...');
- // Stop normal behavior
- event.preventDefault();
- $.ajax({
- type: "GET",
- url: "functions/ajax.php",
- data: {
- func: "activate",
- email: mail,
- activation: code
- },
- error: function() {
- formWrapper.clearMessages();
- displayError('Error while contacting server, please try again');
- },
- success: function(data) {
- if(data == "success") {
- formWrapper.clearMessages();
- displaySuccess('You can now login to Your account');
- } else if(data == "failed") {
- formWrapper.clearMessages();
- displayError('Invalid code/email, please try again');
- } else if(data == "activated") {
- formWrapper.clearMessages();
- displayError('Account already activated');
- }
- }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement