Manage Learn to apply best practices and optimize your operations.

Remove all commas and validate to a usable float/integer

Get rid of commas and then validate the field to make sure it contains all usable positive numbers.

Since Javascript doesn't like to add on commas (wink), get rid of them and then validate the field to make sure it contains all usable positive numbers.

If a non-usable number is found, it redirects you back to the field, selects the fields contents for you and turns the field background to yellow. When it is corrected, the field background will turn back to white (onBlur). These colors are, of course, changeable.

Enjoy, -Mike


Step 1: Paste this into your JS header:

function IsInt (string)
	{if(string == 0) 
	  { 
	  var val = parseFloat (string);
	  return val > -1
	  }
	 else 
	  {
	  var val1 = string / 1;
	  var val = parseFloat(val1);
	  return val > -1
	  }	
	}

Step 2: Paste this into your fields onBlur event:

var f = document.forms[0];

//remove all commas in a number
newString = this.value.replace(/,/g , "" ); 
this.value = newString;

//Test for usable value
if( !IsInt(this.value)) {alert( "This field contains a value that is negative 
or is not an integer or decimal." ) ; 
this.focus() ; this.style.backgroundColor='yellow'} 
if( IsInt(this.value))  {this.style.backgroundColor='white'} ;
	

Step 3: Paste the following into the onFocus field event:

select()

Dig Deeper on Lotus Notes Domino Administration Tools

SearchWindowsServer
Search400
  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

SearchDataCenter
SearchContentManagement
Close