Enter Specific Phrase/Password Example

Let’s say you want to require a visitor to enter a specific phrase to access a PDF or discount. This is good for events, conferences, webinars, etc.

For example, during an event, you give attendees the special pass code “ChicagoEvent”.

You would create a Box with a Custom Field (e.g. Custom Field 1) and use the custom JavaScript below. In this example, the box would not allow visitors to submit the form they type ChicagoEvent in the Custom Field 1. If they type anything else it would display the error message “Please Enter the Correct Passcode”.

Custom JS Boxes – Event Trigger: After Form Validation

var cust_1 = $("#form_input_custom1").val();
if(cust_1.toLocaleLowerCase() != "ChicagoEvent"){
   return "Please Enter the Correct Passcode";
}

This code works by checking the input value and returning an error message if incorrect. Returning a string from After Form Validation will show that string as an error message. For more information on the form processing pipeline, see Custom JS Overview for Developers