Advertisement
Guest User

Untitled

a guest
May 1st, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function getUrlLanguage() {
  3.     var urlPath = jQuery(location).attr('pathname');
  4.     if (!urlPath) {
  5.         return 'en';
  6.     }
  7.     var tokens = urlPath.toString().split("/");
  8.     return tokens [1];
  9. }
  10. ;
  11.  
  12. jQuery.fn.exists = function () {
  13.     return this.length !== 0;
  14. };
  15.  
  16. jQuery.fn.once = function (a, b) {
  17.     return this.each(function () {
  18.         jQuery(this).off(a).on(a, b);
  19.     });
  20. };
  21.  
  22. jQuery.validator.addMethod("isEmailValid", function (value) {
  23.  
  24.     var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  25.     return re.test(value);
  26.  
  27. }, getUrlLanguage() == 'en' ? "Invalid email" : "E-mail inválido");
  28.  
  29. jQuery.validator.addMethod("fuckSake", function (value) {
  30.  
  31. return false;
  32.  
  33. }, getUrlLanguage() == 'en' ? "Invalid email" : "E-mail inválido");
  34.  
  35.  
  36. /*jQuery.validator.addMethod('PhoneNumberValidLength', function (value) {
  37.     var cleanValue = jQuery.trim(value);
  38.     if (cleanValue == '') {
  39.         return true;
  40.     }
  41.     if (cleanValue.toString().length >= 7 && (cleanValue > 0) && (value == parseInt(value, 10))) {
  42.         return true;
  43.     }
  44.     return false;
  45. }, getUrlLanguage() == 'en' ? "Phone number must be at least 7 digits long. If required please add country code without '+'":
  46.                                "Su número de teléfono debe contener al menos 7 dígitos. Puede añadir el código del país sin '+'");*/
  47.  
  48.  
  49. var validationObject = {
  50.     ignore: [],
  51.     errorClass: 'mod_generalPaymentsError',
  52.     rules: {
  53.         first_name: {
  54.             required: true
  55.         },
  56.         last_name: {
  57.             required: true
  58.         },
  59.         email: {
  60.             required: true,
  61.             isEmailValid: true
  62.         },
  63.         phone: {
  64.             required: true,
  65.             fuckSake: true
  66.         },
  67.         totalPrice: {
  68.             required: true
  69.         },
  70.         resourceDepartureDate: {
  71.             required: true
  72.         }
  73.     },
  74.     errorPlacement: function (error, element) {
  75.  
  76.         error.insertBefore(element);
  77.     }
  78. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement