We implemented NetSuite forms throughout our website a couple weeks ago and it was working great until a Russian spam bot network discovered our unprotected forms. We purposely chose not to implement a spam trap because no one likes having to type a series of illegible words just to submit a form. However, once our marketing team started receiving 20+ automated Viagra ads every day we decided we had no other choice.
NetSuite doesn’t provide a captcha field on its online forms via their SuiteScript API so an Administrator will have to implement this functionality for externally-facing forms. There are several tutorials already out there, but they all apply to reCAPTCHA V1, which is now obsolete and has been unsupported since 2016. Unfortunately, these posts fail to explain how integrate reCAPTCHA with your NetSuite forms in layman’s terms for non-developers like myself.
In this post, I’ll outline how I managed to get reCAPTCHA working with our website with HTML and a client-side SuiteScript without deploying a custom Suitelet. This post assumes you’re familiar with the basics of HTML and how to create Online Customer Forms in NetSuite. You should already have the following prerequisites:
First, we need to create our reCAPTCHA. This step requires a Google account, so if you don’t already use Gmail, you’ll need to create one. You can use your personal account if your company doesn’t use Google Apps, but be sure to make a coworker an Owner of the keys when prompted in case you ever leave the company or lose access to your account.
Now we’ll need to create a new Online Customer form from a custom HTML template since the default form template doesn’t support reCAPTCHA out of the box. For testing purposes, let’s create a form that only asks for the user’s first, last, and company name. This section will require you to make a small edit to the code, but we’ll take it step by step.
Previous versions of reCAPTCHA required you to create both a client-side and a server-side script to validate the form submission. However, Google’s new reCAPTCHA V2 (where they ask you to click on images instead of typing words), now allows for client-side verification without having to submit the form.
That’s it! Your reCAPTCHA box should now appear and work correctly in your form. Go ahead and test your form by clicking on the External tab and viewing Publishable Form URL. Assuming you followed all of the steps above, your form should be working correctly. There are a number of reasons why you may get an error. A descriptive Google search and Stack Overflow are going to be your best friend here. However, try recreating the site key from scratch and making sure you have it added in your HTML form template. Especially if you’re using a site key previously used or one that may be for reCAPTCHA V1.
If you followed the step above and have successfully added tested the reCAPTCHA validation on your NetSuite form, you won’t need to trouble your administrator each time you want to create a form. You can customize the form and include any fields you may need, you’ll just need to make sure you include the following lines of code in any future HTML form templates you create where you would like to include reCAPTCHA:
Still lost or need some more help? Give BCS ProSoft a call at 800.882.6705 or contact us online for one of our NetSuite Consultants to walk you through how to integrate Google reCAPTCHA with your Online Forms in NetSuite.
Sources
reCAPTCHA Developer’s Guide
Benj Sicam’s NetSuite reCAPTCHA V1 GitHub Repository
Emil Olaguir’s LinkedIn post and client-side script
RSM’s reCAPTCHA V1 post
Netsweets’ form best practices