// 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();
  }
}