// This script and many more are available free online at
// The JavaScript Source!! http://javascript.internet.com

// Make sure a field does accept more than a specified limit.
// This is useful to limit the amount of text accepted in a
// TEXTAREA field, since they do not have an attribute that
// controls this.
function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit) {
    field.value = field.value.substring(0, maxlimit);
  } else {
    // otherwise, update 'characters left' counter
    countfield.value = maxlimit - field.value.length;
  }
}

function stopBubble() {
    var iKey;
    var eAny_Event = window.event;
    iKey = eAny_Event.keyCode;
    if(iKey==13) {
        window.event.cancelBubble=true;
    }
}


// This function verifies that a field's value is numeric.
// If the value is not numeric, an alert box is presented
// and focus is set to the field.
//
// It can be used like this within an HTML INPUT tag:
//  onBlur=isNumeric(this);
//
function isNumeric(field) {
  var num = field.value;
  if(isNaN(num)) {
   alert('This must be a number.');
    field.select();
    field.focus();
  }
}
/*
 this function is to nullify the fields when user just enter empty spaces 
 and submit page.because validation framwork validwhen rule is concidering
 empty spaces also a value which is voilating the some commmen principles 

*/

function isBlank(val){
	if(val==null){
	
	return true;
	}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r"))
		{
		
		return false;
		}
		}
	return true;
	
	}
	function setNullIfBlank(obj){if(isBlank(obj.value)){obj.value="";}}
//--------------------end of setNullIfBlank function -------------------//