[ Index ]

PHP Cross Reference of MyBB 1.8.29

title

Body

[close]

/jscripts/ -> regvalidator.js (source)

   1  $(function () {
   2      $.validator.messages.required = lang.js_validator_not_empty;
   3  
   4      $('#registration_form').validate({
   5          rules: {
   6              username: {
   7                  required: true,
   8                  minlength: regsettings.minnamelength,
   9                  maxlength: regsettings.maxnamelength,
  10                  remote: {
  11                      url: 'xmlhttp.php?action=username_availability',
  12                      type: 'post',
  13                      dataType: 'json',
  14                      data:
  15                      {
  16                          my_post_key: my_post_key
  17                      },
  18                  },
  19              },
  20              email: {
  21                  required: true,
  22                  email: true,
  23                  remote: {
  24                      url: 'xmlhttp.php?action=email_availability',
  25                      type: 'post',
  26                      dataType: 'json',
  27                      data:
  28                      {
  29                          my_post_key: my_post_key
  30                      },
  31                  },
  32              },
  33              email2: {
  34                  required: true,
  35                  email: true,
  36                  equalTo: '#email'
  37              },
  38          },
  39          messages: {
  40              username: {
  41                  required: lang.js_validator_no_username,
  42                  minlength: lang.js_validator_username_length,
  43                  maxlength: lang.js_validator_username_length,
  44              },
  45              email: lang.js_validator_invalid_email,
  46              email2: lang.js_validator_email_match,
  47          },
  48          errorPlacement: function (error, element) {
  49              if (element.is(':checkbox') || element.is(':radio'))
  50                  error.insertAfter($('input[name=\"' + element.attr('name') + '\"]').last().next('span'));
  51              else
  52                  error.insertAfter(element);
  53          }
  54      });
  55  
  56      var requiredfields = JSON.parse(regsettings.requiredfields);
  57      $.each(requiredfields, function () {
  58          var input_type = 'input';
  59          var depth = "";
  60          if (this.type == "textarea") {
  61              input_type = "textarea";
  62          } else if (this.type == "multiselect") {
  63              input_type = "select";
  64              depth = "[]";
  65          } else if (this.type == "checkbox") {
  66              depth = "[]";
  67          }
  68  
  69          $(input_type + '[name="profile_fields[' + this.fid + ']' + depth + '"]').rules('add', {
  70              required: true,
  71          });
  72      });
  73  
  74      if (regsettings.captchaimage == "1" && regsettings.captchahtml == "1") {
  75          $('#imagestring').rules('add', {
  76              required: true,
  77              remote: {
  78                  url: 'xmlhttp.php?action=validate_captcha',
  79                  type: 'post',
  80                  dataType: 'json',
  81                  data:
  82                  {
  83                      imagehash: function () {
  84                          return $('#imagehash').val();
  85                      },
  86                      my_post_key: my_post_key
  87                  },
  88              },
  89              messages: {
  90                  required: lang.js_validator_no_image_text
  91              }
  92          });
  93      }
  94  
  95      if (regsettings.securityquestion == "1" && regsettings.questionexists == "1") {
  96          $('#answer').rules('add', {
  97              required: true,
  98              remote: {
  99                  url: 'xmlhttp.php?action=validate_question',
 100                  type: 'post',
 101                  dataType: 'json',
 102                  data:
 103                  {
 104                      question: function () {
 105                          return $('#question_id').val();
 106                      },
 107                      my_post_key: my_post_key
 108                  },
 109              },
 110              messages: {
 111                  required: lang.js_validator_no_security_question
 112              }
 113          });
 114      }
 115  
 116      if (regsettings.regtype !== "randompass") {
 117          $.validator.addMethod('passwordSecurity', function (value, element, param) {
 118              return !(
 119                  ($('#email').val() != '' && value == $('#email').val()) ||
 120                  ($('#username').val() != '' && value == $('#username').val()) ||
 121                  ($('#email').val() != '' && value.indexOf($('#email').val()) > -1) ||
 122                  ($('#username').val() != '' && value.indexOf($('#username').val()) > -1) ||
 123                  ($('#email').val() != '' && $('#email').val().indexOf(value) > -1) ||
 124                  ($('#username').val() != '' && $('#username').val().indexOf(value) > -1)
 125              );
 126          }, lang.js_validator_bad_password_security);
 127  
 128          if (regsettings.requirecomplexpasswords == "1") {
 129              $('#password').rules('add', {
 130                  required: true,
 131                  minlength: regsettings.minpasswordlength,
 132                  remote: {
 133                      url: 'xmlhttp.php?action=complex_password',
 134                      type: 'post',
 135                      dataType: 'json',
 136                      data:
 137                      {
 138                          my_post_key: my_post_key
 139                      },
 140                  },
 141                  passwordSecurity: '',
 142                  messages: {
 143                      minlength: lang.js_validator_password_length,
 144                      required: lang.js_validator_password_length,
 145                  }
 146              });
 147          } else {
 148              $('#password').rules('add', {
 149                  required: true,
 150                  minlength: regsettings.minpasswordlength,
 151                  passwordSecurity: '',
 152                  messages: {
 153                      minlength: lang.js_validator_password_length,
 154                      required: lang.js_validator_password_length
 155                  }
 156              });
 157          }
 158  
 159          $('#password2').rules('add', {
 160              required: true,
 161              minlength: regsettings.minpasswordlength,
 162              equalTo: '#password',
 163              messages: {
 164                  minlength: lang.js_validator_password_length,
 165                  required: lang.js_validator_password_length,
 166                  equalTo: lang.js_validator_password_matches
 167              }
 168          });
 169      }
 170  });


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref