GlideSystem - addErrorMessage(Object message)

Adds an error message for the current session.

Use getErrorMessages() to retrieve a list of error messages currently being shown.

Table 1. Parameters
Name Type Description
message Object The message to add.
Table 2. Returns
Type Description
void

Scoped equivalent

To use the addErrorMessage() method in a scoped application, use the corresponding scoped method: Scoped GlideSystem - addErrorMessage(Object message).

gs.include("PrototypeServer");
  var ValidatePasswordStronger = Class.create();
  ValidatePasswordStronger.prototype = {
       process : function() {
          var user_password = request.getParameter("user_password");
          var min_len = 8;
          var rules = "Password must be at least " + min_len + 
             " characters long and contain a digit, an uppercase letter, and a lowercase letter.";
          if (user_password.length() < min_len) {
             gs.addErrorMessage("TOO SHORT: " + rules);
             return false;
          }
          var digit_pattern = new RegExp("[0-9]", "g");
          if (!digit_pattern.test(user_password)) {
             gs.addErrorMessage("DIGIT MISSING: " + rules);
             return false;
          }
          var upper_pattern = new RegExp("[A-Z]", "g");
          if (!upper_pattern.test(user_password)) {
             gs.addErrorMessage("UPPERCASE MISSING: " + rules);
             return false;
          }
          var lower_pattern = new RegExp("[a-z]", "g");
          if (!lower_pattern.test(user_password)) {
             gs.addErrorMessage("LOWERCASE MISSING: " + rules);
             return false;
          }
          return true; // password is OK
       }
  }
[edit]