var old_val = ''

function check_match(elem, match, done_editing)
{
  var value   = elem.value
  var pos     = value.search(match);
  var invalid = (pos >= 0)

  if (invalid)
    elem.value = old_val // reset the old value
  else 
    old_val = value      // save the current value

  if (done_editing) old_val = ''

  return !invalid
}
