Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to prevent semi colon in searchable keywords

nitin gupta1
Tera Contributor

Guys-

I have one field on form and I want to restrict it when anyone put ; on that field ( string field)

I want to show error message and want to clear only ; not entire data that he putted

Can anyone suggest how we can achieve this?

I want this when he is filling that form and field presents on the form

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

Something like this will work, onChange of whatever this field is (short_description in this example).

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

	if (newValue.indexOf(';') != -1) {
		alert ('Semi-colon(s) removed');
		g_form.setValue('short_description', newValue.replace(/;/g, '')); //replace all ; with nothing in this field
	}
   
}