function inputValidator() {
  var attribute_exists;
  var TextInputs = document.getElementsByTagName("INPUT");
  for (counter = 0;counter < TextInputs.length;counter++) {
    attribute_exists = TextInputs[counter].getAttribute('field_type');
    if (attribute_exists && TextInputs[counter].type == "text" && TextInputs[counter].id.length > 0) {
      addEvent('onkeyup', validateInput, document.getElementById(TextInputs[counter].id));
      //TextInputs[counter].onkeydown = function (e) {return validateInput(e, this);}
    }
  }
}
function validateInput(e) {
  //http://www.quirksmode.org/js/events_properties.html
  var targ;

  if (!e) var e = window.event;

  if (e.target) {
    targ = e.target;
  }	else if (e.srcElement) {
    targ = e.srcElement;
  }
	if (targ.nodeType == 3) {// defeat Safari bug
		targ = targ.parentNode;
  }
  var source = document.getElementById(targ.id);
  var attribute_value = source.getAttribute('field_type');

  switch (attribute_value) {
    case 'alphanumeric':
      source.value = source.value.replace(/[^0-9a-z\. ]/ig, '');
      break;
    case 'float':
      source.value = source.value.replace(/[^0-9\.]/g, '');
      break;
    case 'int':
      source.value = source.value.replace(/[^0-9]/g, '');
      break;
    case 'phone':
      source.value = source.value.replace(/[^0-9\-\(\) ]/g, '');
      break;
  }
}
onLoadCalls.push(new onLoadCall('inputValidator',''));
