Guest User

Untitled

a guest
Jul 10th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. $("#dialog").dialog({
  2. bgiframe: true,
  3. autoOpen: false,
  4. height: 230,
  5. modal: true,
  6. buttons: {
  7. 'Logga in': function() {
  8. var name = $("#username"),
  9. password = $("#password"),
  10. allFields = $([]).add(name).add(password),
  11. tips = $("#vtips");
  12.  
  13. var bValid = true;
  14. allFields.removeClass('ui-state-error');
  15.  
  16. bValid = bValid && checkLength(name,"Skriv inn änvandarnamn",3,14);
  17. bValid = bValid && checkLength(password,"Skriv inn lösenord",5,24);
  18. bValid = bValid && checkRegexp(name,/^[a-zA-Z0-9\s\xc5\xc4\xd6\xe5\xe4\xf6]+$/i,"Felaktig änvandarnamn.");
  19. bValid = bValid && checkRegexp(password,/^[a-zA-Z0-9\s\xc5\xc4\xd6\xe5\xe4\xf6]+$/,"Felaktig lösenord");
  20.  
  21. if (bValid) {
  22. $.ajax({
  23. url: '/interactive/',
  24. type: 'POST',
  25. data: 'username=' + name.val() + '&password=' + password.val(),
  26. cache: false,
  27. success: function (html) {
  28. if (html == 'ok') {
  29. $('#dialog').dialog('close');
  30. top.location.href = '/aa';
  31. } else {
  32. updateTips('Fel lösenord!');
  33. }
  34. }
  35. });
  36. }
  37.  
  38. },
  39. Avbryta: function() {
  40. $(this).dialog('close');
  41. }
  42. },
  43. close: function() {
  44. allFields.val('').removeClass('ui-state-error');
  45. }
  46. });
Add Comment
Please, Sign In to add comment