Manage Learn to apply best practices and optimize your operations.

You can force numbers-only entries

This tip describes how to force numbers-only entries.

The following Javascript only allows a user to enter numbers in a field, and also limits the number of digits he/she can enter.

It works by constantly checking the field value via the setTimeout method every .05 seconds, removing non-numeric characters, and truncating the length if necessary.

This works in Notes R5 and above, INCLUDING in the client !

Remember to include the clearTimeout statement in the field's onBlur event, or the function will keep on running until the user exits the form.

In the JSHeader

//Declare Global variables
var fName = ""
var nLen = 0

function limitField( f, n){
 // Transfer local variables to globals
 fName = f;
 nLen = n;

function limitLength(){
 if (fName != "" && nLen > 0){
  with (document.forms[0].elements[fName]){
   v  = value
   v = numsOnly(v)
   if (v.length > nLen) {
    value = v.substr(0,nLen)
    value = v
   timerID = setTimeout("limitLength()", 50);

function numsOnly (inString) {
 // Removes all non-numeric chars
 var s = inString
 var nVals = "1234567890";     // acceptable chars; add + - . if floating values desired
 var i;
 var tmp = "";
 // Search through string and append to unfiltered values to tmp.
 for (i = 0; i < s.length; i++) {
  var c = s.charAt(i);
  if (nVals.indexOf(c) != -1){
   tmp += c;
 return tmp;


Field onFocus event
limitField(, 10)

Field onBlur event

Dig Deeper on Lotus Notes Domino Administration Tools

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 ...