Manage Learn to apply best practices and optimize your operations.

JavaScript Domino directory name validation

This JavaScript will check if an exact match is found in the Domino Directory. If no match is found, an alert message will appear and return focus to the field.

View member feedback to this tip.

This JavaScript will check if an exact match is found in the Domino Directory. If no match is found, an alert message will appear and return focus to the field.

The function takes four parameters, which are explained in the source code. The exact match in the Domino directory is case insensitive. The main goal is to make sure the name is able to be resolved in the Domino directory.

If you omit the myOrg argument to the isInNab function, the common name will be searched instead of the canonical name. However, the name will only be matched up to the number of characters you enter. A mail routing failure may occur if duplicate are names found. For my purposes, I am at least sending the organization to the function. Passing the organization will place distinct delimiters around the name to get the exact match. ("CN=" is the prefix and "O=/..." is the suffix)

Below is a JavaScript code snippet that 
may be added to the onBlur event 
of a text field to validate against the 
Domino directory.

var myHost = window.location.protocol +
 "//" + + "/names.nsf"; 
var myOrg = "Sandbox"; 
var alertmsg = "Name not found in Addressbook. 
Please try again."; isInNab( this, myHost, myOrg, alertmsg );

Below is the code that may be added to the JSHeader of the form 
that contains the field that is being validated.

// Checks a single public address book to 
confirm if a name is found.
This function is intended for IE browsers 
that provide the Microsoft.XMLDOM

fld   = The web text field that contains the SendTo name.
nabDB = The URL that points to the Domino directory. 
myOrg  = The organization name used in the
 Domino hierarchy. If you pass an empty myOrg
                   value, the comman name will be 
searched in the ($Users) view if the Domino Directory.
                   You can also send an ORG/OU, ORG/OU/OU..., etc 
as an aurgument.
alertMsg = The message that appears to the 
user if the name is not found in the Domino Directory.                   

function isInNab ( fld, nabDB, myOrg, alertMsg ) { 

 if ( ! alertMsg ) {
  alertMsg = "Name not found in public address book.";
 myOrg = myOrg.toLowerCase();
 function loadXML(xmlFile ) {
 function verify() {
   if (xmlDoc.readyState != 4)  {
     return false;
 // Note: The domain in nabDB is usually the 
same as the HTML page that calls the URL.
 //            IE may prompt you if you to execute 
a call to a foriegn domain or not run if you cross 
  //            domain boundaries between the 
caller and callee (pending browser security settings).
 var resourcePrefix = "/$users/?ReadViewEntries&startkey=cn=";
  var resourceSuffix = "";
 var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
 var person = fld.value.toLowerCase();

 resourceSuffix += "&count=1";  
 A user may use a dialog picker to get the name value.
In order to build a lookup based on 
common name or abbreviated name, 
we must make sure we start with a common name.
 Perform a loose @Name( [CN]... ) of the person value.
Change the lookFor array and Switch statement below 
to include other hierarchy transformations if needed.

 var pos = 0;
 var cnt = 0; // Used to count when /org and o=org is transformed. 
                         // It will be determined invalid 
if a target exist after all transformations.
 var lookFor = new Array( 2 ) 
 lookFor[ 0 ] = "/" + myOrg;
 lookFor[ 1 ] = "cn=";
 lookFor[ 2 ] = "/o=";

 for ( target = 0 ; target < 3 ; target++ ) {
  pos = person.indexOf( lookFor[ target ] );

  if ( pos != -1 ) {
   switch( target ) {
    case 0:
     person = person.substr( 0, pos );

    case 1:
     if ( person.length >= pos + 3 ) {
      person = person.substr( pos + 3 );

    case 2:
     person = person.substr( 0, pos );
 loadXML( nabDB + resourcePrefix + 
person + resourceSuffix );
 var fullName = 
 Now we will append the "/o=myOrg" 
onto the end of person if myOrg was passed
 before we see if it is contained in the 
result from the Domino directory
 if ( myOrg != "" ) {
  person += "/o=" + myOrg;
  if ( ( fullName.context.text.toLowerCase() ).
indexOf( person ) == -1 || cnt == 2 ) {
    alert( alertMsg );


This tip is a variation a previously published tip, JavaScript version of @DBLookup and @DBColumn.

—Carlos Andres J.

Do you have comments on this tip? Let us know.

This tip was submitted to the tip exchange by member Dennis Potts. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Dig Deeper on JavaScript for Lotus Notes Domino

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...