Advertisement
Guest User

Untitled

a guest
Dec 17th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 2.41 KB | None | 0 0
  1. $(document).ready(function()
  2. {
  3.     $("input, textarea, select").not('.nostyle').uniform();
  4.    
  5.     $.validator.addMethod('regexp', function(value, element, param)
  6.     {
  7.         return this.optional(element) || value.match(param);
  8.     }, 'This is not have an accepted value!');
  9.    
  10.     $("#login_form").validate({
  11.         rules: {
  12.             username: {
  13.                 required: true,
  14.                 minlength: 6,
  15.                 maxlength: 12,
  16.                 regexp: /^\w+$/
  17.             },
  18.             password: {
  19.                 required: true,
  20.                 minlength: 6,
  21.                 maxlength: 12,
  22.                 regexp: /^\w+$/
  23.             },
  24.             remember: {
  25.                 digits: true
  26.             },
  27.         },
  28.         submitHandler: function(form)
  29.         {
  30.             data_string = $("#login_form").serialize();
  31.             $.pnotify_remove_all();
  32.             $.ajax({
  33.                 type:"POST",
  34.                 url:'login/submit',
  35.                 data:data_string,
  36.                 dataType: 'json',
  37.                 success:function (data) {
  38.                     if (data.output_status == 'Error')
  39.                     {
  40.                         $.pnotify({
  41.                             type: 'error',
  42.                             title: data.output_title,
  43.                             text: data.output_message,
  44.                             icon: 'picon icon24 typ-icon-cancel white',
  45.                             opacity: 0.95,
  46.                             history: false,
  47.                             sticker: false
  48.                         });
  49.                     }
  50.                     else if (data.output_status == 'Notice')
  51.                     {
  52.                         $.pnotify({
  53.                             title: data.output_title,
  54.                             text: data.output_message,
  55.                             icon: 'picon icon16 entypo-icon-warning white',
  56.                             opacity: 0.95,
  57.                             history: false,
  58.                             sticker: false
  59.                         });
  60.                     }
  61.                     else
  62.                     {
  63.                         $.pnotify({
  64.                             type: 'success',
  65.                             title: data.output_title,
  66.                             text: data.output_message,
  67.                             icon: 'picon icon16 iconic-icon-check-alt white',
  68.                             opacity: 0.95,
  69.                             history: false,
  70.                             sticker: false
  71.                         });
  72.                         window.location = 'ctrlpanel';
  73.                     }
  74.                 }
  75.             });
  76.             return false;  //stop the actual form post !important!
  77.         }
  78.     });
  79. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement