Registration JavaScript API

Events

Registration can provide detailed information on user and application state using JavaScript events. These are useful for making customizations-based information gathered at run time, and for using third-party analytics to track specific events.

Registering Event Handlers

To add a handler for an event, use the addHandler method. All events are located within the janrain.events namespace, and handlers should be added within the janrainCaptureWidgetOnLoad function before the janrain.capture.ui.start argument, which loads the Registration UI. For example:

function janrainCaptureWidgetOnLoad() {
  janrain.events.onCaptureLoginSuccess.addHandler(function(event){
    // do stuff
  }
  janrain.capture.ui.start();
}

Event Types

Depending on the event type, different information is passed to the event handler function. Note: Some events do not conform to these types specifically and are documented in detail where they are defined.

Transaction

These events contain information about the latest transaction between the Registration widget and the Registration service. Information included consists of the transaction ID, status, status message, flow name and version, as well as the screen the widget will render next (only when renders is true). Sometimes includes the access token. Example event:

{
  accessToken: "qazxde45rtgbnkiug",
  action: "profile",
  flow: "standard",
  renders: true
  screen: "editProfile",
  status: "success",
  statusMessage: "profileFound",
  transactionId: "fufk86ggk1uqwpfnilytfy2dv2lfsa3m5p2qx50y",
  version: "20160406190849202817",
}

Mail

These events contain information about the email that was just sent. Example event:

{
  to: "user_email@example.com",
  from: "noreply@myorg.com",
  message: "Email sent!"
}

Social

All of these types of events contain the name of the social identity provider being used. Example event:

{
  provider: "facebook"
}

Render

These events contain the flow at the time of rendering, as well as the screen being rendered. If renderingBuiltInScreen is false, the currently-rendered screen will be located in the screen property. If renderingBuiltInScreen is true, the currently-rendered screen will be located in the builtInScreenRendered property. Example event:

{
  flow: { ... },
  renderingBuiltInScreen: false,
  screen: "editProfile"
}

Example event with builtInScreenRendered:

{
  flow: { ... },
  renderingBuiltInScreen: true,
  screen: "editProfile",
  builtInScreenRendered: "accessDenied"
}

Screen

These events contain the name of the screen being displayed.

{
  screen: "editProfile"
}

Access Token

These events contain the access token that was just returned from the Registration service. Example event:

{
  accessToken: "qazxde45rtgbnkiug"
}

Void

These events don’t contain any data, but are still useful for enriching the user experience.

onCaptureAccessDenied

Type: Void
Fires when the user attempts to access information but is not yet authorized. For example, attempting to navigate to their profile without logging in.

onCaptureAccountDeactivateFailed

Type: Transaction
Fires when an error occurs while a user is attempting to deactivate their account.

onCaptureAccountDeactivateSuccess

Type: Transaction
Fires after a user has successfully deactivated their account.

onCaptureAccountReactivateFailed

Type: Transaction
Fires when an error occurs while a user is attempting to reactivate their account.

onCaptureAccountReactivateSuccess

Type: Transaction
Fires after a user has successfully reactivated their account.

onCaptureBackplaneInitFailed

Type: Void
Fires if Backplane has not successfully initialized one minute after the Registration widget initially loads.

onCaptureBackplaneReady

Type: Void
Fires when the Backplane server signals that it is ready to run.

onCaptureContentChange

Type: Void
Fires when the content on a screen is changed. Various actions can fire this event, such as rendering a screen, displaying a validation message, adding or removing fields, and so forth.

onCaptureControlFailed

Type: Transaction
Fires when a control action fails. Control actions are small pieces of logic that can be used to trigger events (such as sending emails). See activateCaptureControl.

onCaptureControlSuccess

Type: Transaction
Fires when a control action succeeds. Control actions are small pieces of logic that can be used to trigger events (such as sending emails). See activateCaptureControl.

onCaptureEmailSent

Type: Mail
Fires when an email was sent to the user. This event fires for all email types sent through the Janrain Registration service (registration, verification, and so on).

onCaptureEmailVerificationFailed

Type: Transaction
Fires when the email verification process has failed. Usually this happens when the user has waited too long to click the verification link in their email.

onCaptureEmailVerificationSuccess

Type: Transaction
Fires when a user successfully verifies their email address.

onCaptureError

Fires when an unexpected error returns from the Registration service. The contents of this event vary depending on the nature of the error.

onCaptureExpiredToken

Type: Void
Fires when a transaction between the Registration widget and service fails due to an expired access token.

onCaptureFederateLogin

Type: Transaction
Fires when a user successfully logs in, and is logged in to all other sites within the federated segment.

onCaptureFederateNoLogin

Type: Transaction
Fires when a user successfully logs in, but was not logged in to other sites within the federated segment.

onCaptureFederateRefreshedToken

Type: Access Token
Fires when a new session is created by SSO. This can indicate that the session was created by the user visiting another site with the federated segment, or that the session was refreshed so that it would not expire.

onCaptureFieldsChanged

Fires upon submission of a form if the field values have changed. The event consists of an object with keys matching the field names changed. The value of each key contains both the new and old values. Example event:

{
  nameOfSomeFieldThatChanged: {
    newValue: "This value was changed!",
    oldValue: "This is the original value."
  }
}

onCaptureForgotPasswordCodeFailed

Type: Transaction
Fires when the user was unable to exchange the forgot password code and reset their password.

onCaptureForgotPasswordCodeSuccess

Type: Transaction
Fires when a user successfully exchanges the forgot password code, but before they change their password.

onCaptureFormError

Fires when a validation error occurs after submitting a form. The event consists of an object enumerating the errors. Example event:

{
  someValidation: "There was an error."
}

onCaptureInvalidToken

Type: Void
Fires when the access token supplied to the Registration service was malformed.

onCaptureLinkAccountError

Fires when an error occurs while attempting to link a social account to a user profile. Example event:

{
  message: "Unable to link accounts.",
  provider: "facebook"
}

onCaptureLoginFailed

Type: Transaction
Fires when a user fails to log in to the Registration service.

onCaptureLoginStart

Fires when the login screen is first shown to the user. The event consists of the screen name and action (either traditionalSignin or socialSignin). Example event:

{
  action: "socialSignin",
  screen: "socialLoginScreen"
}

onCaptureLoginSuccess

Fires when the user has successfully logged in. On initial login, event handlers will receive an Access Token event. On post-login and session refresh event handlers will receive a Transaction event.

onCaptureModalReady

Type: Void
Fires when a modal screen is ready to be shown, before onCaptureScreenShow.

onCapturePhotoUploadSuccess

Type: Void
Fires after a user has successfully uploaded a profile image.

onCapturePostLoginScreen

Type: Transaction
Fires when a post-login screen is displayed to the user. The event only includes the access token on post-login confirmation screens.

onCaptureProfileCookieSet

Fires when the Registration widget sets the janrainCaptureProfileData localStorage key with the user data specified by the flow. The event consists of an object containing the user data. Example event:

{
  firstName: "Alex",
  lastName: "Smith"
}

Fires when a user successfully links an additional social provider account to their current user profile. The event consists of the provider of the new account as well as the new user data. Example event:

{
  provicer: "facebook",
  authProfile: { ... }
}

onCaptureProfileSaveFailed

Type: Transaction
Fires when an error occurs while attempting to save the user’s profile.

onCaptureProfileSaveSuccess

Type: Transaction
Fires when changes to a user profile are saved successfully.

Type: Social
Fires when a user successfully unlinks a social account from their current user profile.

onCaptureRegistrationFailed

Type: Transaction
Fires when an error occurs during a traditional registration.

onCaptureRegistrationStart

Fires when the registration screen is first shown to the user. The event consists of the screen name and action (either traditionalRegister or socialRegister). Example event:

{
  action: "socialRegister",
  screen: "socialRegisterScreen"
}

onCaptureRegistrationSuccess

Type: Transaction
Fires when a user has successfully registered.

onCaptureRegistrationSuccessNoLogin

Type: Transaction
Fires when a user has successfully registered, but there are post-login screens to complete before login is considered complete. The event will not contain an access token.

onCaptureRenderComplete

Type: Render
Fires when the Registration widget has finished initially rendering on the page. This event is not triggered upon subsequent screen changes.

onCaptureRenderStart

Fires before the Registration widget begins rendering any changes to the page. The event consists of the entire flow at the time the event is fired.

onCaptureSaveFailed

Type: Transaction
Fires whenever an error occurs while attempting to save profile data to the Registration service.

onCaptureSaveSuccess

Type: Transaction
Fires whenever data is successfully saved to the Registration service.

onCaptureScreenShow

Type: Screen
Fires when the Registration widget displays a screen to the user.

onCaptureServerValidationFailed

Fires when validation fails after submitting a form and the result is being rendered for the user. The event consists of the error messages from the Registration service. Example event:

{
  errors: [
    "Invalid input"
  ]
}

onCaptureSessionCreated

Type: Access Token
Fires when a new access token is issued by the Registration service.

onCaptureSessionEnded

Type: Void
Fires when the user logs out and the user’s access token is invalidated.

onCaptureSessionFound

Type: Access Token
Fires when an access token is found on page load.

onCaptureSessionNotFound

Type: Void
Fires when no access token is found on page load.

onCaptureTransactionTimeout

Fires when a transaction with the Registration service times out. See janrain.settings.capture.transactionTimeout for information on how to set the timeout threshold. Event consists of the transaction ID that timed out. Example event:

{
  transactionId: "fufk86ggk1uqwpfnilytfy2dv2lfsa3m5p2qx50y"
}

onCaptureValidationComplete

Fires after validating a form before submitting to the Registration service. The event consists of an array of the fields that contain errors. Example event:

{
  fieldsWithError: [
    "firstName",
    "emailAddress"
  ]
}

onCaptureValidationFailed

Fires when a field fails validation. Event consists of information about the field and failed validation. Example event:

{
  field: "emailAddress",
  message: "Email address is invalid",
  parentDiv: Element
}

onCaptureValidationSuccess

Fires when a field passes validation. Event consists of the field name. Example event:

{
  field: Element
}

onModalClose

Type: Void
Fires when the Registration widget modal closes.

onModalOpen

Type: Void
Fires when the Registration widget modal opens.

onProviderLoginCancel

Type: Social
Fires when the user cancels during social authentication.

onProviderLoginComplete

Type: Social
Fires when the Janrain widget has successfully retrieved the user’s profile information from the social identity provider.

onProviderLoginError

Type: Social
Fires when an error occurs during social authentication. Handler functions are called with the JSON error response from the Social Login service.

onProviderLoginStart

Type: Social
Fires when a user clicks a social identity provider button and initiates sign-in.

onProviderLoginSuccess

Type: Social
Fires when the user successfully authenticates with the social identity provider.

onProviderLogoutComplete

Type: Social
Fires once the user has successfully logged out.

onProviderLogoutStart

Type: Social
Fires when the user clicks the logout button in the Registration widget.

Settings

All of the settings below are located within the janrain.settings.capture namespace. For example:

janrain.settings.capture.modalBorderWidth = 4;

Settings must be defined before the janrainCaptureWidgetOnLoad function is called to load the Registration UI.

accessTokenLifeHours

Default: 1 integer

The amount of time that Registration and Single Sign-on sessions should last, in hours.

appId

string Required

The Capture application ID that represents a specific capture app. Example:

janrain.settings.capture.appId = 'x8n7eat5sd984y5nhxbv9ma98e';

backplane

Default: false boolean

Set to true to enable Backplane.

backplaneBlock

Default: 20 integer

The amount of time to wait for a Backplane response, in seconds. This setting only applies to Backplane 2.

backplaneBusName

string

The name of the Backplane bus that the Registration widget should listen to. This setting is required when using Backplane.

backplaneChannelExpires

string

Controls when the Backplane channel cookie expires. Uses same syntax as cookies. Example:

janrain.settings.capture.backplaneChannelExpires = 'Fri, 3 Aug 2001 20:47:11 UTC';

backplaneLibrary

Default: https://ssl-cdn.janrainbackplane.com/ string

Specifies the domain from which to load the Backplane source.

backplaneReplayOnPageLoad

Default: false boolean

Replays all messages from the long-term Backplane cache on each page load.

backplaneServerBaseUrl

Default: https://backplane1.janrainbackplane.com/v1.2 string

Specifies the Backplane server base URL.

backplaneVersion

Default: 1.2 string

Which version of Backplane to use. Can be ‘1.2’ or ‘2’.

beforeJanrainCaptureWidgetOnLoad

Default: [] array

Any functions added to this array will be executed immediately before the Registration widget loads.

captureServer

string Required Specifies the URL used to communicate with the Registration service. This is automatically set by Janrain for you, but needs to be updated if you wish to use a custom CNAME for your registration service. Example:

janrain.settings.capture.captureServer = "https://login.mycooldomain.com";

cdnUrl

Default: https://ssl-cdn.janraincapture.com string

Allows you to override the CDN domain that the Janrain assets are loaded from. Note: This is for specialized configurations only (you probably don’t want to change this).

clientId

string Required

A client ID from your Registration application. You should create a new client ID for each property that you deploy Janrain Registration on. Example:

janrain.settings.capture.clientId = "k8n534hdguau36be6bgrnx5vhn";

confirmModalClose

Default: false boolean

If set to true, prompts the user before closing any modal dialog.

cookieDomain

string

Changes the domain that cookies are created with. If not set, a domain is not specified for cookies upon creation and most browsers default to the current domain.

federate

Default: false boolean

Set to true to enable Single Sign-on.

federateLogoutCallback

function

An optional function that is called after a user logs out of a Single Sign-on session.

federateLogoutUri

string

This setting is required if you are using Single Sign-on, and each site in your SSO segment must have its own federateLogoutUri page. You can make this a blank page or something more elaborate. It is called in a hidden iframe from whichever site the user logs out on. It is commonly used to host custom behavior implemented once a user signs out, such as ending a server session on all other sites the user has visited, or clearing cookies. This value must be an absolute URL. For example:

janrain.settings.capture.federateLogoutUri = 'https://mycooldomain.com/logout'

federateNoRefresh

Default: 'false' string

If set to 'true' (Note: this is the string “true”, not boolean true), SSO will not attempt to refresh the Registration session upon expiration.

federateSegment

string

Specifies which SSO segment the current property belongs in.

federateServer

string Required

The URL of the Janrain Single Sign-on server.

federateSupportedSegments

Default: [] array

Segments that the current site is allowed to federate with using Single Sign-on.

federateXdReceiver

string

Each site that uses Single Sign-on must host a Cross Domain (XD) Receiver page that the SSO communication script can be loaded on. For example, the following HTML might be hosted at https://mycooldomain.com/xdcomm.html:

<!DOCTYPE html>
<meta charset=utf-8>
<title>Single Sign On Receiver</title>
<script src="https://d1lqe9temigv1p.cloudfront.net/js/lib/xdcomm.js"></script>

flowName

Default: 'default' string

Specifies which flow should be used. See also mobileFlowName.

flowVersion

Default: 'HEAD' string

Specifies which version of the flow to load. Typically we recommend using a fixed version in production, and using 'HEAD' (always points to the latest version) during development.

hasSettings

Default: false boolean

If set to true, the Registration widget will load additional settings defined by Janrain for this site. Note: This is for specialized configurations only (you probably don’t want to change this).

hideSavedProfileMessageDelay

integer

The amount of time before the “Your profile has been saved.” message disappears, in miliseconds. If this is not set, the message will persist.

keepProfileCookieAfterLogout

Default: false boolean

If set to true, the janrainCaptureProfileData local storage key will not be deleted when a user logs out. The value will be cleared once the user closes their browser. See also setProfileCookie, and an example in Customizing Registration.

language

Default: 'en-US' string

Specifies the language to use. The janrain.settings.capture.language setting corresponds to the languages defined in the flow.

Note that this is a different setting from janrain.settings.language, which is associated with the Social Login Registration UI and only supports a limited set of languages; see the Social Login JavaScript API for more information.

logoutLinksClass

Default: 'capture_end_session' string

Specifies the class that will be targeted to attach the Registration sign-out handler function. The class must be on an anchor or button tag to work. For example, either of the following would work:

<a href="#" class="capture_end_session">Log Out</a>

<button class="capture_end_session">Log Out</button>

mergeFlow

string

Specifies the screen to render for account merge. If not set, it falls back to janrain.settings.capture.registerFlow, and finally 'socialRegister'.

mobileFlowName

string

Specifies the flow to use if the Registration widget detects it is running in a mobile browser. If not set, it falls back to janrain.settings.capture.flowName.

mobileStylesheets

array

Stylesheet URLs that are loaded if the Registration widget detects it is running in a mobile browser.

modalBorderColor

Default: '#000' string

Note: We recommend that you not use this setting, and instead use janrain.settings.capture.noModalBorderInlineCss and custom CSS to style the Registration widget modals.

Specifies the border color of the Registration widget modals.

modalBorderOpacity

Default: 0.5 float

Note: We recommend that you not use this setting, and instead use janrain.settings.capture.noModalBorderInlineCss and custom CSS to style the Registration widget modals.

Specifies the border opacity of the Registration widget modals.

modalBorderRadius

Default: 10 integer

Note: We recommend that you not use this setting, and instead use janrain.settings.capture.noModalBorderInlineCss and custom CSS to style the Registration widget modals.

Specifies the border radius of the Registration widget modals.

modalBorderWidth

Default: 10 integer

Note: We recommend that you not use this setting, and instead use janrain.settings.capture.noModalBorderInlineCss and custom CSS to style the Registration widget modals.

Specifies the border width of the Registration widget modals.

modalCloseHtml

string

HTML that will be used for the modal close button. If not set, the Registration widget will use its default button.

modalCloseImage

Default: 'https://cdn.rpxnow.com/rel/img/17c96fc4b9c8464d1c95cd785dd3120b.png' string

The URL of an image to use as the modal close button. Note: This setting will be ignored if you have also set janrain.settings.capture.modalCloseHtml.

modalOpenClass

Default: 'capture_modal_class' string

Specifies the class that will be targeted to attach the Registration sign-in modal opener handler function.

noModalBorderInlineCss

Default: false boolean

If set to true, the Registration widget will not add any inline styles for modal borders. Use this if you plan on overwriting the modal styles using CSS. This effectively disables the following settings:

noStyling

Default: false boolean

If set to true, the default Janrain CSS will not be loaded.

quiltUrl

Default: 'https://d3hmp0045zy3cs.cloudfront.net' string

Allows you to override the CDN domain from which the Janrain UI assets are loaded. Note: This is for specialized configurations only (you probably don’t want to change this).

quiltVersion

Default: '2.2.19' string

Allows you to override the version of the Janrain UI assets. Note: This is for specialized configurations only (you probably don’t want to change this).

recaptchaUrl

string

Specifies the URL from which to load the Google Recaptcha script. Defaults to https://www.google.com/recaptcha/api/js/recaptcha_ajax.js for version 1 and https://www.google.com/recaptcha/api.js for version 2. Version is specified by janrain.settings.capture.recaptchaVersion.

recaptchaVersion

Default: 1 integer

Specifies which version of Recaptcha to use.

redirectFlow

Default: false boolean

If set to true, the Registration widget will use the redirect flow as defined in Social Login Redirect Flow.

redirectOnLogin

Default: false boolean

If set to true, the Registration widget will redirect the user to the value set in janrain.settings.capture.redirectUri.

redirectUri

string

This is required if using Single Sign-on with Registration. This value is used to identify the site within a segment.

Additionally, this setting can be used in conjunction with janrain.settings.capture.redirectOnLogin to redirect a user to another location after a successful traditional sign-in.

registerFlow

Default: 'socialRegister' string

Specifies the screen to render for social registration.

responseType

string

Accepts either 'token' or 'code'. Determines whether or not a Registration access token or an authorization code is returned after a successful sign-in. Typically, you want this set to 'token'. For more information, read Managing Sessions with Registration.

returnExperienceUserData

array

A list of schema attributes that will be saved to the local storage key janrainCaptureReturnExperienceData as a stringified JSON object. See an example in Customizing Registration.

screenToRender

string

Specifies which screen to display. This can be used to override the default flow screen in certain scenarios.

setProfileCookie

Default: false boolean

If set to true, the user profile will be saved to the local storage key janrainCaptureProfileData as a stringified JSON object. See an example in Customizing Registration.

socialRegistrationCompleteRedirect

string

Specifies a URL that the user will be redirected to upon a successful social registration.

socialRegistrationRedirect

string

Specifies a URL that the user will be redirected to upon initiating social registration.

socialRegistrationRedirectUrlCondition

object

A set of key-value pairs that must match the Registraion server response or user data returned. If any of the values do not match the server response, no redirect will occur. In the example below, the redirect would only occur for users with the first name “Alex”:

janrian.settings.capture.socialRegistrationRedirectUrlCondition = {
  'firstName': 'Alex'
}

ssoFileUrl

Default: 'https://ssl-cdn.janrainsso.com' string

Allows you to override the URL Single Sign-on assets are loaded from. Note: This is for specialized configurations only (you probably don’t want to change this).

stylesheets

array

A list of stylesheet URLs that the Registration widget will load.

thinRegistration

Default: false boolean

If set to true, the Registration widget will not display any post-login screens after a successful log-in.

transactionTimeout

integer

If set, will impose a timeout on all interactions with the Janrain Registraion service (in miliseconds). If a transaction takes longer than the time specified, the onCaptureTransactionTimeout event is fired.

Functions

activateCaptureControl

janrain.capture.ui.activateCaptureControl(controlName);

Activates a Control action defined in the flow. Typically this is used to trigger emails.

applySettings

janrain.capture.ui.applySettings(clientSettings);

Accepts an object containing client settings that can be used by the Registration widget to populate dynamic information within registration forms.

createCaptureSession

janrain.capture.ui.createCaptureSession(accessToken);

Creates a Registration session from an access token returned from the Registration API. In general the Registration service handles session creation for you, so you don’t need to call this manually. See Managing Sessions with Registration for information on when you would need to call createCaptureSession.

endCaptureSession

janrain.capture.ui.endCaptureSession();

Invalidates the current login session.

getClientSettings

janrain.capture.ui.getClientSettings();

Returns a copy of the client settings.

getEngageCookie

janrain.capture.ui.getEngageCookie(name);

Returns a piece of the return experience data stored after a successful social login by name. Name can be one of the following:

  • 'expected_tab' - This is the last tab that the user clicked on in the Social Login widget.
  • 'welcome_info_name' - This is the display name reported by the identity provider, used to greet the user upon returning to the site.
  • 'login_tab' - This is the tab with which the user logged in.

getFailedLogins

janrain.capture.ui.getFailedLogins();

Returns the number of failed login attempts. This number resets when a successful login is made.

getProfileCookieData

janrain.capture.ui.getProfileCookieData(propertyName);

Returns the specified property from the JSON string stored in the localStorage key janrainCaptureProfileData. This data disappears after the user closes their browser. See an example in Customizing Registration.

getPublicProfile

janrain.capture.ui.getPublicProfile(publicProfileScreenName, profileUuid);

Renders the public profile screen. The name of the public profile screen as well as the UUID of the profile are required.

getReturnExperienceData

janrain.capture.ui.getReturnExperienceData(propertyName);

Returns the specified property from the JSON string stored in the localStorage key janrainCaptureReturnExperienceData. This data persists even after the user closes their browser. See an example in Customizing Registration.

hasActiveSession

janrain.capture.ui.hasActiveSession();

Returns true if the registration widget has an access token, false otherwise.

linkSocialAccount

janrain.capture.ui.linkSocialAccount(providerName);

Note: This function requires that Social Login is also configured.

Starts the link account flow and prompts the user to log in to the provider specified. providerName can be the name of any provider configured in your Social Login settings.

janrain.capture.ui.modal.close();

Closes the Registration widget login modal.

janrain.capture.ui.modal.closeConfirm();

Closes the Registration widget login modal, but first prompts the user to confirm.

janrain.capture.ui.modal.open();

Opens the Registration widget login modal.

janrain.capture.ui.modal.setBorder(width);

Sets the Registration widget login modal border width.

janrain.capture.ui.modal.setBorderColor(hexColor);

Sets the Registration widget login modal border color. Accepts a string with a hex value.

janrain.capture.ui.modal.setBorderOpacity(opacity);

Sets the Registration widget login modal border opacity. Accepts a numeric value between 0 and 1.

janrain.capture.ui.modal.setBorderRadius(radius);

Sets the Registration widget login modal border radius. Accepts an integer.

janrain.capture.ui.modal.setOverlayZIndex(index);

Sets the Registration widget login modal background overlay zIndex. Accepts an integer.

noop

janrain.capture.ui.noop();

A noop function.

postCaptureForm

janrain.capture.ui.postCaptureForm(formName[, fieldValues]);

Posts a form to the Registration service and executes any server-side validation defined in the flow. formName must be the name of a form that exists in the flow.

Optionally takes an object containing key-value pairs to populate the form with data. The key names must match the field names in the form. If fieldValues is omitted, the Registration widget extracts the field values from the specified form on the page.

Here is an example of how to programmatically submit a form with user-entered data:

var formName = 'editProfileForm';

janrain.capture.ui.postCaptureForm(formName);

Here is an example submitting the same form, but this time we will also provide the values to submit:

var formName = 'editProfileForm';
var fieldValues = {
  firstName: 'Jake',
  lastName: 'Anders'
};

janrain.capture.ui.postCaptureForm(formName, fieldValues);

registerFunction

janrain.capture.ui.registerFunction(functionName, validationFunction);

Registers a validation function that can be used for custom client-side validation. The custom validation must be added to the field definition in the flow in order for the registered function to actually be invoked.

The function registered with janrain.capture.ui.registerFunction should return true or false, and will be passed the following arguments:

  • elementName - The name of the form element being validated.
  • elementValue - The value of the form element being validated.
  • validation - A validation object from the Registration widget with some methods for manipulating the element being validated.

Below is an example of a custom validation function that enforces a minimum length of 12:

function mustBeAtLeastTwelve(elementName, elementValue) {
  return elementValue.length >= 12;
}

janrain.capture.ui.registerFunction('mustBeAtLeastTwelve', mustBeAtLeastTwelve);

renderScreen

janrain.capture.ui.renderScreen(screenName[, noScreenHistory]);

Renders a screen with the Registration widget. screenName must be the name of a screen defined in the flow. If noScreenHistory is set to true, the current screen will not be available via the back button within the new screen.

scriptLoader

janrain.capture.ui.scriptLoader(scriptSource[, callbackFunction]);

A lightweight utility for loading additional scripts after initial page load that provides functionality for callbacks and timeouts. scriptSource should be an absolute URL. The callbackFunction can be specified initially or later via the setCallback method. The script will not be loaded until the load method is called.

Below is a full example illustrating how scriptLoader can be used to load somelib.js, but times out after 500 milliseconds:

function callbackSuccess() {
  console.log('Success!');
}

function timeoutCallback(errorEvent) {
  console.error('Oh no! A bad thing happened:', errorEvent);
}

var scriptSource = 'https://www.somecdn.com/somelib.js'

janrain.capture.ui.scriptLoader(scriptSource)
  .setCallback(callbackSuccess)
  .setTimeoutCallback(timeoutCallback)
  .setTimeoutLimit(500)
  .load();

setCustomHtml

janrain.capture.ui.setCustomHtml(builtInScreenName, htmlString);

Allows you to overwrite the default inner HTML content of the built-in Registration widget screens. The following built-in screens can be overwritten:

  • accessDenied
  • dialog
  • retrievingUserData

setFieldAttribute

janrain.capture.ui.setFieldAttribute(fieldName, attributeName, attributeValue);

Sets a specified attribute on a field. This method can be called before the form is rendered, and the Registration widget will set the attribute appropriately.

setNoReturnExperience

janrain.capture.ui.setNoReturnExperience();

Disables the greeting for returning customers that re-authenticate.

setValidator

janrain.capture.ui.setValidator(validationName, validatorFunction);

Allows you to override one of the built-in validator functions. Below is a list of valid values for validationName:

  • hasValue
  • isDate
  • isValidMinYears
  • isValidMinLength
  • isValidMaxLength
  • isValidMaxNumericLength
  • isValidFormat
  • isValidMatch
  • isUnique

start

janrian.capture.ui.start([flowUrl]);

Initializes the Registration widget. It should be called once within the janrainCaptureWidgetOnLoad function defined on your page. Optionally accepts an absolute URL for the flow (used only in complex configurations).

Scroll ↓