Siebel CRM Desktop for Microsoft Outlook Administration Guide > Customizing Siebel CRM Desktop > Process of Customizing Objects in Siebel CRM Desktop >

Defining Validation Rules for a Phone Number


To define validation rules for the phone number in a contact record or an account record, you can add the following regular expression to the forms_xx.xml file:

var phonetest = new RegExp(/\(?[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-9]{4}/);

item["Work Phone #"] != '' ? (item["Work Phone #"].match(phonetest) != null ? true : false) : true;

where:

  • RegExp describes the regular expression. The part of the phone number that the user enters must match the pattern that you defined in the RegExp expression. If the number contains fewer than 10 digits, then Siebel CRM Desktop creates a validation failure message.
  • match(phonetest) causes Siebel CRM Desktop to search for the substring. The real value must not be the same as the pattern.

In this example, the following phone numbers are valid:

  • 1111111111
  • (999)-888-4444
  • 222.888.9999

The following phone numbers are not valid:

  • 1111111111 - x123
  • phone: 1111111111
  • +1 555.666.8888
  • 11111111
  • 222.aaa.8888

To define another validation, you can specify another regular expression in the rule tag of the forms_xx.xml file.

This number format is specific to telephone networks in the United States. For a different country, you must use the numbering format that is specific to that country.

To define validation rules for a phone number

  1. Use an XML editor to open the forms_xx.xml file.

    For more information, see About Files in the Customization Package.

  2. Add the following code to the forms_xx.xml file:

    <rule message="#msg_business_phone_validation">

    <expression>

    <![CDATA[

    var phonetest = new RegExp(/\(?[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-

    9]{4}/);

    item["Work Phone #"] != '' ? (item["Work Phone #"].match(phonetest)

    != null ? true : false) : true;

    ]]>

    </expression>

    </rule>

    <rule message="#msg_mobile_phone_validation">

    <expression>

    <![CDATA[

    var phonetest = new RegExp(/\(?[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-

    9]{4}/);

    item["Cellular Phone #"] != '' ? (item["Cellular Phone

    #"].match(phonetest) != null ? true : false) : true;

    ]]>

    </expression>

    </rule>

    <rule message="#msg_home_phone_validation">

    <expression>

    <![CDATA[

    var phonetest = new RegExp(/\(?[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-

    9]{4}/);

    item["Home Phone #"] != '' ? (item["Home Phone #"].match(phonetest)

    != null ? true : false) : true;

    ]]>

    </expression>

    </rule>

    <rule message="#msg_fax_phone_validation">

    <expression>

    <![CDATA[

    var phonetest = new RegExp(/\(?[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-

    9]{4}/);

    item["Fax Phone #"] != '' ? (item["Fax Phone #"].match(phonetest) !=

    null ? true : false) : true;

    ]]>

    </expression>

    </rule>

Siebel CRM Desktop for Microsoft Outlook Administration Guide Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Legal Notices.