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.
Service portal : Email Validation script not working - Known Error
  • >
  • Knowledge Base
  • >
  • Known Error (Knowledge Base)
  • >
  • Service portal : Email Validation script not working
KB0744940

Service portal : Email Validation script not working


2977 Views Last updated : Sep 14, 2024 public Copy Permalink
KB Summary by Now Assist

Description

Validation Script for Email type where UI Type is selected as "Service portal / All" does not work, allowing records to be saved with incorrect email addresses.

Steps to Reproduce

 

  1. Check the validation script is true for Email type for Mobile/Service portal.
  2. Go to 'New Email Account' catalog item in portal.
  3. Enter an invalid email.
  4. Submit.

    Notice no "Invalid Email Address" error message is shown. The record is saved without validating the email address input.

Workaround

This problem has been identified as a future possible product enhancement. You can subscribe to this Known Error article by clicking the Subscribe button at the top right of this form to be notified when more information will become available.

As a workaround, any validation of an email field can be done via onSubmit Catalog Client Script:
 

function onSubmit() {
//Type appropriate comment here, and begin script below
 var newEmail = g_form.getValue('<fieldname>');

 function isValidEmail(email) {
  return !!email.toString().match(/(^[a-z0-9]([0-9a-z\-_\.]*)@([0-9a-z_\-\.]*)([.][a-z]{3})$)|(^[a-z]([0-9a-z_\.\-]*)@([0-9a-z_\-\.]*)(\.[a-z]{2,5})$)/i);
 }

 if(!isValidEmail(newEmail)) {
  g_form.addErrorMessage('Invalid email.');
  return false;
 } else {
  return true;
 }
}


Related Problem: PRB1302806

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.