Discussions

Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
Now is the time to ask your NetSuite-savvy friends and colleagues to join the NetSuite Support Community! Refer now! Click here to watch and learn more!
Update your Profile with your Support type to get your Support Type badge.
Expand your NetSuite knowledge by joining our Ask A Guru Live sessions. RSVP on this event now.
Make Your Voice Heard: What Tech & ERP Topics Should We Explore in our Next Webinar?? We’re all ears! Vote now, and the poll runs until January. Poll for ERP | Poll for Tech.
Uncover the power of data with the Analytics Hub —your ultimate guide to mastering NetSuite Saved Searches and Reports. Simplify the complex and unlock your organization's true potential. Dive into the Analytics Hub now and soar to new heights!

Kilimanjaro - how can we extend validation patterns

edited Mar 15, 2024 8:04PM in Ask A Guru 5 comments

Hello! We use SuiteCommerce Advanced Kilimanjaro and I have a question regarding being able to extend the Backbone.Validation.patterns fields. Ultimately I would like to call a new pattern we're creating from within code as such; Backbone.Validation.patterns.customPattern.test(<string to test>).

In the third_parties directory there is the backbone-validation module that includes backbone-validation.js, which is where the base logic is for validation. In the suitecommerce/BackboneExtras module there's Backbone.Validation.patterns.js, which looks like it's an extension to the base .patterns object:

define('Backbone.Validation.patterns'
,	[	'Backbone'
	,	'underscore'
	,	'Backbone.Validation'
	]
,	function (
		Backbone
	,	_
	)
{
	'use strict';

	_.extend(Backbone.Validation.patterns,
	{
		// Same as email but is more restrictive and matches the same emails as the Netsuite backend UI
	    // Source: https://system.netsuite.com/javascript/NLUtil.jsp__NS_VER=2014.1.0&minver=154&locale=en_US.nlqs
	  //    (Search for NLValidationUtil_SIMPLE_EMAIL_PATTERN)
		email: /^[-a-z0-9!#$%&'*+/=?^_`{|}~]+(?:\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*@(?:[a-z0-9]+(?:-+[a-z0-9]+)*\.)+(?:xn--[a-z0-9]+|[a-z]{2,16})$/i

		//This validation is less restrictive than standard and matches with the used in Netsuite backend
	,	netsuiteUrl: /^(https|http|ftp|file):\/\//

	,	netsuiteFloat: /^-{0,1}([0-9])+(\.{1}[0-9]+)?$/

	,	netsuiteInteger: /^-{0,1}([0-9])+$/
		//Allow numbers bettwen 000.00 and 000100.00 ending with optional %
	,	netsuitePercent: /^0*((([0-9]{1,2})(\.[0-9]{1,2})?%?$)|(100(\.0{1,2})?%?$))/

		//Allow any character 7 or more times (this is the validation that the netsuite backend form does on phone type fields)
	,	netsuitePhone: /^.{7,}$/

	});

	return Backbone.Validation.patterns;
});

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!

Leaderboard

Community Whiz

Quarter 2 (Apr-Jun 2025)

This Week's Leaders

This Month's Leaders

All Time Leaders