docs: function (elements, rule, type) {
              var foundElements = [];
              // The length is a special case, where the placeholders
              // of the search pattern (X,Y) first must be replaced by
              // the value(s) specified in the attribute.
              if (type === "length") {
                  for (var i = 0; i < elements.length; i++) {
                      // Length attribute is not a substitute for the
                      // required attribute. Length just states what
                      // min/max-length an element should have, if it
                      // is filled in.
                      if (elements[i].value === "")
                          continue;
                      var length = elements[i].getAttribute("data-length");
                      var format = elements[i].getAttribute("data-format");
                      // Format can be either max or min. The length
                      // attribute combined with the format attribute
                      // must only contain one digit for it to be
                      // considered valid.
                      if (format === "max") {
                          if (/^([0-9]$)/.test(length))
                              var string = new RegExp(rule.replace("X,Y", "0," + length));
                          else
                              continue;
                      } else if (format === "min") {
                          if (/^([0-9]$)/.test(length))
                              var string = new RegExp(rule.replace("X,Y", length + ","));
                          else
                              continue
                      } else {
                          // Even if a format attribute is not set, the validation
                          // of the element should differ, depending on how the
                          // length attribute is set up.
                          if (/^([0-9]\,[0-9]$)/.test(length))
                              // Normal case, a max and min is specified ("1,5").
                              var string = new RegExp(rule.replace("X,Y", length));
                          else if (/^([0-9]\,$)/.test(length))
                              // A single digit with a comma at the end is to be
                              // considered minimum length ("1,")
                              var string = new RegExp(rule.replace("X,Y", length));
                          else if (/^([0-9]$)/.test(length))
                              // A single digit without a comma should be treated
                              // as max length, but for the regex to work a zero
                              // needs to be added at the beginning. ("5") => ("0,5")
                              var string = new RegExp(rule.replace("X,Y", "0," + length));
                          else
                              // If none of the above checks out it is not a valid
                              // value, skip this one and move to the next.
                              continue;
                      }
                      if (string.test(elements[i].value) === false)
                          foundElements.push(elements[i]);
                  }
              } else if (type === "date") {
                  // Date is also a special case, where the regex pattern
                  // needs to be build depending on the format specified.
                  // The date delimiter can be almost any non-word
                  // character, therefore the regex pattern \W.
                  var delimiterPattern = new RegExp(/([\W])/), delimiterMatches;
                  for (var i = 0; i < elements.length; i++) {
                      var elementValue = elements[i].value;
                      if (elementValue.length < 1)
                          continue;
                      // Retrieve the date format from the element
                      var format = elements[i].getAttribute("data-format");
                      if (format === null)
                          format = this.settings.dateFormat;
                      if ((delimiterMatches = delimiterPattern.exec(format)) !== null) {
                          var dateComponents = format.split(delimiterMatches[0]);
                          var dateBrokenDown = elementValue.split(delimiterMatches[0]);
                          var date = [];
                          // Begin building the date pattern
                          var validDatePattern = "^(";
                          for (var x = 0; x < dateComponents.length; x++) {
                              // Create an array out of the components and inputed date
                              // for later use, to make sure that it is an actual date.
                              var key = dateComponents[x][0].toUpperCase();
                              date[key] = dateBrokenDown[x];
                              // Dates and months should have an interval-length,
                              // so that if they are set to max 2 digits (MM) the
                              // user should not have to write a leading zero, as
                              // this often isn't how date parsers read a date.
                              if (key !== "Y")
                                  var length = "1," + dateComponents[x].length;
                              else
                                  var length = dateComponents[x].length;
                              validDatePattern += "\\d{" + length + "}";
                              // Add the delimiter, but not to the last digit.
                              if (dateComponents.length > x+1)
                                  validDatePattern += "\\" + delimiterMatches[0];
                          }
                          // Close the date pattern.
                          validDatePattern += ")$";
                          var validDate = new RegExp(validDatePattern);
                          if (validDate.test(elementValue) === false) {
                              foundElements.push(elements[i]);
                          } else {
                              // Even if the date has the right format, it may not be an
                              // actual date. This will make sure that the date exists.
                              // The year must be four digits, so add the first two digits
                              // if they are missing.
                              if (date["Y"].length == 2)
                                  date["Y"] = new Date().getFullYear().toString().substr(0,2) + date["Y"];
                              // Also, remove 0 if month and date begins with one.
                              date["M"] = date["M"].replace(/^0/, '');
                              date["D"] = date["D"].replace(/^0/, '');
                              // Create the date object, and retrieve the individual
                              // components to compare it to the inputed date. If the
                              // date is wrong, the parsed date will not be the same
                              // as the user inputed one (JS will parse for example
                              // 31st of february as a valid date).
                              var dateObject = new Date(date["Y"], (date["M"]-1), date["D"]);
                              var dateParsed = dateObject.getFullYear() +''+ (dateObject.getMonth()+1) +''+ dateObject.getDate();
                              var dateString = date["Y"] +''+ date["M"] +''+ date["D"];
                              if (dateParsed !== dateString)
                                  foundElements.push(elements[i]);
                          }
                      }
                  }
              } else {
                  var string = new RegExp(rule);
                  for (var i = 0; i < elements.length; i++) {
                      if (string.test(elements[i].value) === false) {
                          if (type === "required" ||
                              type !== "required" && elements[i].value.length > 0)
                              foundElements.push(elements[i]);
                      }
  
                  }
  
              }
              return foundElements;
          }