Guest User

Untitled

a guest
Sep 14th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. /*
  2. * novaCMS - jQuery Login
  3. * ---------------------------
  4. * @author Leon Hartley
  5. * @desc It's used to build the visual
  6. * elements of the CMS design.
  7. * @template Nova
  8. */
  9.  
  10. $(document).ready(function() {
  11.  
  12. $('form').submit(function() {
  13. var username = $("input#username").val();
  14. var password = $("input#password").val();
  15.  
  16. if(username == "" || password == "") {
  17. $('.error').html('<div class="container">All fields are required! Make sure you populate each field!</div>');
  18. $('.error').slideDown('slow').delay(1700).slideUp('slow');
  19. return false;
  20. }
  21.  
  22. var dataString = 'username='+ username + '&password=' + password;
  23.  
  24. $.ajax({
  25. type: "POST",
  26. url: "index/login",
  27. data: dataString,
  28. success: function(data) {
  29. if(data == 'yes')
  30. {
  31. console.log('Correct details provided, logging in..');
  32. document.location = 'me';
  33. return false;
  34. }
  35. else
  36. {
  37. $('.error').html('<div class="container">The details you provided where incorrect!</div>');
  38. $('.error').slideDown('slow').delay(1700).slideUp('slow');
  39. return false;
  40. }
  41. }
  42. });
  43. return false;
  44. });
  45. });
Add Comment
Please, Sign In to add comment