Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Max length not restricting form field - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Max length not restricting form field
KB0750494

Max length not restricting form field


2446 Views Last updated : Sep 14, 2022 public Copy Permalink
KB Summary by Now Assist

Issue

A form field with a max length set allows you to input more characters than the specified max length

 

Release

All

 

Cause

This is a known platform issue: PRB825271

Resolution

This can be resolved with an onChange client script that monitors the field and rejects the new value if it is over the desired length. 

1) Navigate to System Definition > Client Scripts and click the New button at the top of the list 
2) Give the script a name 
3) Select the target table 
4) Set the UI Type as desired 
5) Set the Type to onChange 
6) Select the target field in Field name 
7) Add script similar to the script shown below, replace 2 with the desired limit
8) Submit the record 

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

// check the new value length, if it's greater than 2, reset to the old value
if(newValue.toString().length > 2) {
g_form.setValue('u_target_field', oldValue);
return;
}
}

The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.