def on_leave
      val = getvalue
      #$log.debug " FIELD ON LEAVE:#{val}. #{@values.inspect}"
      valid = true
      if val.to_s.empty? && @null_allowed
        #$log.debug " empty and null allowed"
      else
        if !@values.nil?
          valid = @values.include? val
          raise FieldValidationException, "Field value (#{val}) not in values: #{@values.join(',')}" unless valid
        end
        if !@valid_regex.nil?
          valid = @valid_regex.match(val.to_s)
          raise FieldValidationException, "Field not matching regex #{@valid_regex}" unless valid
        end
        # added valid_range for numerics 2011-09-29 
        if !in_range?(val)
          raise FieldValidationException, "Field not matching range #{@valid_range}, above #{@above} or below #{@below}  "
        end
      end
      # here is where we should set the forms modified to true - 2009-01
      if modified?
        set_modified true
      end
      # if super fails we would have still set modified to true
      super
      #return valid
    end
def on_leave
      val = getvalue
      #$log.debug " FIELD ON LEAVE:#{val}. #{@values.inspect}"
      valid = true
      if val.to_s.empty? && @null_allowed
        #$log.debug " empty and null allowed"
      else
        if !@values.nil?
          valid = @values.include? val
          raise FieldValidationException, "Field value (#{val}) not in values: #{@values.join(',')}" unless valid
        end
        if !@valid_regex.nil?
          valid = @valid_regex.match(val.to_s)
          raise FieldValidationException, "Field not matching regex #{@valid_regex}" unless valid
        end
        # added valid_range for numerics 2011-09-29 
        if !in_range?(val)
          raise FieldValidationException, "Field not matching range #{@valid_range}, above #{@above} or below #{@below}  "
        end
      end
      # here is where we should set the forms modified to true - 2009-01
      if modified?
        set_modified true
      end
      # if super fails we would have still set modified to true
      super
      #return valid
    end
upon leaving a field
 returns false if value not valid as per values or valid_regex
 2008-12-22 12:40 if null_allowed, don't validate, but do fire_handlers