SHARE
TWEET

Untitled

a guest Nov 25th, 2016 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //Валидация на полетата към лизинговата поръчка
  3.    
  4. var $btn = $('button[name="submit"]');
  5.  
  6.  
  7.  
  8. var name = $('#name').val();
  9.  
  10.  
  11.  
  12. var password = $('#egn').val();
  13.  
  14.  
  15.  
  16. var phone = $('#phone').val();
  17.  
  18.  
  19.  
  20. var emailf = $('#emailf').val();
  21.  
  22.  
  23.  
  24. var address1 = $('#address1').val();
  25.  
  26.  
  27.  
  28. var address2 = $('#address2').val();
  29.  
  30.  
  31.  
  32. var $errorField = $('.help-block');
  33.  
  34.  
  35.  
  36. var $formGroup = $('.form-group');
  37.  
  38.  
  39.  
  40. var result;
  41.  
  42.  
  43.  
  44. $btn.on('click', function() {
  45.  
  46.  
  47.  
  48.     $.post('index.php?route=quickcheckout/checkout/validationlizing', $('form').serialize(), function(callback) {
  49.  
  50.         console.log(result)
  51.  
  52.         result = JSON.parse(callback);
  53.  
  54.  
  55.  
  56.         if(result.error) {
  57.  
  58.  
  59.  
  60.             $errorField.text('');
  61.  
  62.  
  63.  
  64.             $formGroup.removeClass('has-error');
  65.  
  66.  
  67.  
  68.             $.each(result.errors, function(errorGroup, credit_errors) {
  69.  
  70.  
  71.  
  72.                 $('.form-group:has(#' + errorGroup + ')').addClass('has-error');
  73.  
  74.  
  75.  
  76.                 $.each(credit_errors, function(index, error) {
  77.  
  78.  
  79.  
  80.                     $('#' + errorGroup + ' + p').append(error + '<br>');
  81.  
  82.  
  83.  
  84.                 });
  85.  
  86.  
  87.  
  88.             });
  89.  
  90.  
  91.  
  92.         }
  93.  
  94.  
  95.  
  96.         if(result.success) {
  97.  
  98.  
  99.  
  100.             window.location = result.redirect;
  101.  
  102.  
  103.  
  104.         }
  105.  
  106.  
  107.  
  108.     });
  109.  
  110.  
  111.  
  112.     return false;
  113.  
  114.  
  115.  
  116. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top