Customizing Validation and Other Logic

Important. Most of the content on this page deals with a legacy feature of the Akamai Identity Cloud (in this case, the JavaScript SDK). If you are currently an Identity Cloud customer and are using the JavaScript SDK, that SDK is still supported. However, if you’re new to the Identity Cloud the JavaScript SDK is no longer available. Instead, you should use Hosted Login for your login and registration needs.

How do I make a field required? Optional?

To make a field required, add or update a field to include the rule “required” with value “true”, as in the example below. If you wish to make an already-required field optional, you can either remove the validation or set the value to “false”. If creating a new field, remember to add the new field to the relevant forms in order to utilize it.

  "label": "My Required Field",
  "name": "myRequiredField",
  "schemaAttribute": "optIn.status",
  "type": "text",
  "validation": [
      "message": "This field is required",
      "rule": "required",
      "value": true

Note. Prefer to use Console and Registration builder to work with fields? Then click here.

How do I add Captcha to my forms?

To add Captcha to a form, you need to make changes in your Flow, your form markup, and your JavaScript settings.

  1. In your Flow, make a GET call to the /config/{app}/flows/{flow}/forms/{form} endpoint to verify you will be modifying the correct form. Once verified, add the “captcha” feature to your form and make a PUT request to the same endpoint:
      "features": [
      "fields":   [
         ...      ] 
    Note that, in the preceding code snippet, the name of the feature is set to captcha. That name is not mandatory: you can give the feature any name you want (e.g., identityCloudCaptcha). But while the name itself doesn't matter, whatever name you use in this step must be exactly the same name you reference in step 2. Compare the highlighted red text in this step with the highlighted red text in step 2 to see what we mean.
  2. In your form markup, add the {* captcha *} JTL tag to your form:
    <div style="display:none;" id="traditionalRegistration">
      {* #registrationForm *}
          <!-- ... -->
          {* captcha *}
          <!-- ... -->
      {* /registrationForm *}
    Again, note that the field name (shown in red) referenced in this step must match the field name defined in step 1.
  3. In your JavaScript settings, add the recaptchaVersion = 2 setting to specify the version of Captcha to render:
    janrain.settings.capture.recaptchaVersion = 2;
  4. Enable Invisible reCaptcha (optional). You can also enable invisible reCaptcha by adding an additional JavaScript setting:
    janrain.settings.capture.recaptchaInvisible = true;

Invisible reCaptcha only presents a challenge to the user if that user is suspected of being a bot. If not, no challenge is presented, and the user continues on as if reCaptcha wasn’t even installed.  For better bot management, please also see your Akamai representative about our line of Bot Manager products.

How do I enforce age restrictions/gating?

The birthdate field in the standard flow already supports age-gating and defaults to a minimum age of 16; simply include it on your forms where needed. What follows are instructions on how to modify this field or add additional age-gated fields.

To enforce age restrictions, you can add or update a dateselect field such that it has a validation object with the minYears (and also required) rules. Then, you can add this field to the traditionalRegistration and ssocialRegistration screens (the registrationForm and socialRegistrationForm forms in your Flow, respectively). Below is an example birthday field that only allows users 18 or older to register. Remember to add the new field to the relevant forms in order to utilize it.

  "label": "Birthday",
  "name": "birthday",
  "schemaAttribute": "birthday",
  "type": "dateselect",
  "validation": [
      "rule": "required",
      "value": "true",
      "message": "Birthdate is required"
      "rule": "minYears",
      "value": 18,
      "message": "You must be at least 18 years old to register"
Note. If you wish to implement site-specific (API client specific) age-gating, this is supported; however, age-gating is not configurable via the Configuration API. Please contact your Akamai representative for more information. If you're using Hosted Login, click here to learn how to implement age-gating using Hosted Login authorization rules.