Advertisement
Guest User

wp2pgpmail-validate.js

a guest
Sep 30th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if ( typeof(alert_message_phone) == 'undefined' ) { var alert_message_phone = 'Please enter a valid phone number. Most US/Canada and International formats accepted.'; }
  2. jQuery(document).ready(function (a) {
  3.     a("#sendmail").attr('disabled', false);
  4.     a(".wp2pgpmail").each(function () {
  5.         a(this).validate({
  6.             rules: {
  7.                 "wp2pgpmail-secret": {
  8.                     required: true,
  9.                     digits: true,
  10.                     maxlength: 2
  11.                 }
  12.             },
  13.             errorPlacement: function (a, b) {
  14.                 if (b.is(":radio") || b.is(":checkbox")) {
  15.                     a.appendTo(b.parent().parent())
  16.                 } else {
  17.                     a.insertAfter(b)
  18.                 }
  19.             },
  20.         submitHandler: function(form) {
  21.         var message = '';
  22.         var label = '';
  23.             for(i=0; i<form.elements.length; i++){
  24.              champ = form.elements[i];
  25.              label = form.elements[i].name;
  26.              if (typeof label != "undefined" && label != "" && label != 'form_id' && label != '_wpnonce' && label != 'wp2pgpmail-secret' && label != 'wp2pgpmail-spam' && label != 'wp2pgpmail-submit' && (champ.type == 'text' || champ.type == 'textarea' || (champ.type == 'checkbox' && champ.checked == true) || champ.type == 'select-one'  || (champ.type == 'radio' && champ.checked == true) ) ) {
  27.             label = label.substring(11, label.length );
  28.             label = label.charAt(0).toUpperCase() + label.slice(1);
  29.             label = label.replace(new RegExp("[-]\\d+$", "g"),"");
  30.             label = label.replace(new RegExp("[-]\\d+[\\[][\\]]$", "g"),"");
  31.             label = label.replace(new RegExp("[-]\\d+([\\[].+[\\]])$", "g")," $1");
  32.             message += champ.value + "\r\n";
  33.             champ.value = '-- encrypted data --';
  34.             if ( champ.value != '-- encrypted data --' ) {
  35.                 champ.options[0] = new Option("-- encrypted data --", "-- encrypted data --", false, false);
  36.                 champ.value = '-- encrypted data --';
  37.             }
  38.              }
  39.             }
  40.         message += "\r\n" + form._ip.value + "]\r\n";
  41.         form._message.value = message;
  42.         if ( encrypt() ) {
  43.             form.submit();
  44.         }
  45.         }
  46.         })
  47.     });
  48.     a.validator.addMethod("phone", function (a, b) {
  49.         a = a.replace(/[\+\s\(\)\.\-\ ]/g, "");
  50.         return this.optional(b) || a.length > 9 && a.match(/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/)
  51.     }, alert_message_phone);
  52.     a(".wp2pgpmail-date-picker").datepicker({
  53.         minDate: "-70y",
  54.         changeMonth: true,
  55.         changeYear: true,
  56.         maxDate: "+10Y +1M +10D",
  57.         yearRange: "c-100:c+20",
  58.         firstDay: 1
  59.     });
  60. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement