Published on July 23, 2019.
Using Client Scripts, you can easily add client-side form validation and manipulation to NetSuite forms. For example, you can immediately validate a field's value when it changes, apply form-level validation when a form is submitted, conditionally hide and show fields, and much more.
Included below is a simple SuiteScript that demonstrates a few of things that you can do with Client Scripts. To experiment with it, apply it to Employee records in a sandbox account. When an employee form loads, you'll see an alert. Try changing an employee's job - and if you change it to "Accountant" notice how the Notes field is hidden. Then change the employee's Phone number to "5555555555" and submit the form.
/** * @NApiVersion 2.0 * @NScriptType ClientScript */ define([], function() { /* This is just an experiment with form validation, conditionally hiding fields, etc. To test it, deploy it against the Employee record type. */ return { fieldChanged: fieldChanged, pageInit: pageInit, saveRecord: saveRecord }; function fieldChanged( context ) { // Shows an alert if the Job field is changed. // If the job is changed to "Accountant," then the notes field is hidden. if ( context.fieldId == 'job' ) { // Get the text value if the selected job. var jobValue = context.currentRecord.getText( { fieldId: 'job' } ); alert( 'You changed the job to: ' + jobValue ); // Get the comments field (object). var commentsField = context.currentRecord.getField( { fieldId: 'comments' } ); if ( jobValue == 'Accountant' ) { commentsField.isDisplay = false; } else { commentsField.isDisplay = true; } } } function pageInit(context) { // Shows an alert when the page loads. alert( 'Welcome to the form.' ); } function saveRecord(context) { // Executed after the submit button is pressed, but before the form is submitted. // If the phone is "5555555555," an alert is shown, and the form is rejected. if ( context.currentRecord.getText('phone') == '5555555555' ) { alert ('Sorry, but that phone number is not allowed.'); return false; } return true; } });
Comments? Questions? Feel free to reach out to me.
Hello, I’m Tim Dietrich. I design and build custom software for businesses running on NetSuite — from mobile apps and Web portals to Web APIs and integrations.
I’ve created several widely used open-source solutions for the NetSuite community, including the SuiteQL Query Tool and SuiteAPI, which help developers and businesses get more out of their systems.
I’m also the founder of SuiteStep, a NetSuite development studio focused on pushing the boundaries of what’s possible on the platform. Through SuiteStep, I deliver custom software and AI-driven solutions that make NetSuite more powerful, accessible, and future-ready.
Copyright © 2025 Tim Dietrich.