jsm

net/sf/jsm/widgets/validators/jsmNumbersOnlyValidator.js

Summary

No overview generated for 'net/sf/jsm/widgets/validators/jsmNumbersOnlyValidator.js'


Class Summary
JsmNumbersOnlyValidator A validator which will only return true of the value only contains numbers

/**
 * Creates a new JsmNumbersOnlyValidator
 * @class A validator which will only return true of the value only contains numbers
 * @constructor
 */    
  function JsmNumbersOnlyValidator() {  
  } 
  
  /** Validates that the view components value contains only numbers; 
   * Currently only supports text fields
   * @param {JsmTable} table The table this widget is attached to
   * @param {int} rowIdx The index of the row
   * @param {int} columnIdx The index of the column
   * @param theViewComponent  
  */
  JsmNumbersOnlyValidator.prototype.validate = function(table, rowIdx, columnIdx, theViewComponent) {
  	retVal = false;  
	if (!jsm.noud(theViewComponent)) {
		if (theViewComponent.type == 'text') {
		  	if (theViewComponent.value.search(/^\d*$/) == 0) {  	
		  		retVal = true;
		  	} else {
		  		alert("The value '" + theViewComponent.value + "' is invalid. Only numbers [0-9] are allowed.");
		  	}
		 } else {
		 	alert("JsmNumbersOnlyValidator only handles JsmTextField currently. Can not validate!");
		 }
	}
  	return retVal;
  } 

jsm

Documentation generated by JSDoc on Tue Sep 26 08:42:57 2006