Guest User

Untitled

a guest
May 10th, 2016
100
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. RULES.js
  2. $(function() {
  3.  
  4.     //********************************************************
  5.     //*** Define rule sets to apply to multiple elements
  6.     //********************************************************
  7.  
  8.     var ruleSetRequired = {
  9.         required: true,
  10.     };
  11.     var ruleSetText = {
  12.         required: true,
  13.         minlength: 1,
  14.     };
  15.     var ruleSetZip = {
  16.         required: true,
  17.         minlength: 5,
  18.         maxlength: 10,
  19.     }
  20.     var ruleSetEmail = {
  21.         required: true,
  22.         email: true,
  23.     }
  24.     var ruleSetDate = {
  25.         required: true,
  26.         date_string: true,
  27.         date_string_val_check: true,
  28.     }
  29.     var ruleSetSSN = {
  30.         required: true,
  31.         ssn: true,
  32.     }
  33.     var ruleSetPhone1 = {
  34.         require_phone_group: [1, ".p_phone_input"],
  35.         //phoneUS: true,
  36.     }
  37.     var ruleSetPhone2 = {
  38.         require_phone_group: [1, ".g_phone_input"],
  39.         //phoneUS: true,
  40.     }
  41.     var ruleSetEmail1 = {
  42.         required: true,
  43.         equalTo: ".email",
  44.         email: true,
  45.     }
  46.     var ruleSetEmail2 = {
  47.         required: true,
  48.         equalTo: ".g_email",
  49.         email: true,
  50.     }
  51.  
  52.     //********************************************************
  53.     //*** validate form focusout/onkeyup/submit
  54.     //********************************************************
  55.  
  56.     var form = $("#" + $('form').attr('id'));
  57.  
  58.     form.validate({
  59.         //*** Affects error display on focusout
  60.         onfocusout: function(element, event) {
  61.             this.element(element);
  62.         },
  63.  
  64.         //*** Affects error behavior on keyup
  65.         //onkeyup: false,
  66.  
  67.         //*** Affects error message behavior/class
  68.         errorClass: 'customErrorClass',
  69.         errorElement: "div",
  70.         errorPlacement: function (error, element) {
  71.             error.insertAfter(element);
  72.         },
  73.  
  74.         //*** Removes error message class from inputs
  75.         highlight: function(element, errorClass) {
  76.             $(element).removeClass(errorClass);
  77.         },
  78.  
  79.         //*** Custom validation rules
  80.         rules: {
  81.             first_name: ruleSetText,
  82.             g_first_name: ruleSetText,
  83.             last_name: ruleSetText,
  84.             g_last_name: ruleSetText,
  85.             address1: ruleSetText,
  86.             g_address1: ruleSetText,
  87.             city: ruleSetText,
  88.             g_city: ruleSetText,
  89.             state_prov: ruleSetRequired,
  90.             g_state_prov: ruleSetRequired,
  91.             postal_code: ruleSetZip,
  92.             g_zip: ruleSetZip,
  93.             country: ruleSetRequired,
  94.             g_country: ruleSetRequired,
  95.             cell_phone: ruleSetPhone1,
  96.             home_phone: ruleSetPhone1,
  97.             work_phone: ruleSetPhone1,
  98.             g_cell_phone: ruleSetPhone2,
  99.             g_home_phone: ruleSetPhone2,
  100.             g_work_phone: ruleSetPhone2,
  101.             email: ruleSetEmail,
  102.             g_email: ruleSetEmail,
  103.             email_again: ruleSetEmail1,
  104.             g_email_again: ruleSetEmail2,
  105.             ssn: ruleSetSSN,
  106.             dob: ruleSetDate,
  107.             g_dob: ruleSetDate,
  108.             gender: ruleSetRequired,
  109.             g_gender: ruleSetRequired,
  110.             preferred_lang_cd: ruleSetRequired,
  111.             g_preferred_lang_cd: ruleSetRequired,
  112.         },
  113.         //*** Custom validation messages
  114.         messages: {
  115.             first_name: "Please enter your first name",
  116.             last_name: "Please enter your last name",
  117.             address1: "Please enter your address",
  118.             city: "Please enter your city",
  119.             state_prov: "Please select your state",
  120.             postal_code: "Please enter a valid postal code",
  121.             country: "Please select your country",
  122.             email_input: "Please enter a valid email address",
  123.             ssn: "Please enter a valid ssn number",
  124.             phone_input: "Please enter a valid phone number",
  125.             dob: "Please enter a valid Date of Birth",
  126.             gender: "Please select your gender",
  127.             preferred_lang_cd: "Please select your language",
  128.         }
  129.     });
  130.  
  131.     //********************************************************
  132.     //*** Mask Input definitions
  133.     //********************************************************
  134.  
  135.     //$(".postal_code").mask("99999?-9999", { placeholder: "" });
  136.     $(".phone_input").mask("999-999-9999");
  137.     $(".ssn_input").mask("999-99-9999");
  138.     $(".dob_input").mask("99/99/9999");
  139.     $(".g_dob_input").mask("99/99/9999");
  140. });
  141.  
  142.  
  143.  
  144.  
  145. search.js
  146. .           $(document).one('click', '#frm-borrower', function () {
  147.                 if($(this).attr('id') == 'frm-borrower') {
  148.                     //function duplicated from rules.js to borrower.js being called into search.js
  149.                     borrower_validation();
  150.                 }
  151.             });
RAW Paste Data