Here's a copy of a reference under "Syntax" in the FAQ noted below.
Allow specific number entry in a field
(.... i.e. 1.25, 1.50, 1.75, etc...)
so that the only allowable entries are from 0.25 to 24.00 in increments of .25 ?
================================================================
Forum reference: http://gossamer-threads.com/p/000598
----------------------------------------------------------------------------
Response:
You would have to add code to sub validate_record to account for this.
If you haven't already made changes to sub validate_record, replace it with the following code:
sub validate_record {
# --------------------------------------------------------
# Verifies that the information passed through the form and stored in %in matches a valid record. It checks first to see that if we are adding, that a duplicate ID key does not exist.
# It then checks to see that fields specified as not null are indeed not null, finally it checks against the reg expression given in the database definition.
my ($col, @input_err, $errstr, $err, $line, @lines, @data);
if ($in{'add_record'}) { # don't need to worry about duplicate key if modifying
open (DB, "<$db_file_name") or &cgierr("error in validate_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
$line = $_; chomp ($line);
@data = &split_decode($line);
if ($data[$db_key_pos] eq $in{$db_key}) {
return "duplicate key error";
}
}
close DB;
}
foreach $col (@db_cols) {
if ($in{$col} =~ /^\s*$/) { # entry is null or only whitespace
($db_not_null{$col}) and # entry is not allowed to be null.
push(@input_err, "$col (Can not be left blank)"); # so let's add it as an error
}
else { # else entry is not null.
($db_valid_types{$col} && !($in{$col} =~ /$db_valid_types{$col}/)) and
push(@input_err, "$col (Invalid format)"); # but has failed validation.
(length($in{$col}) > $db_lengths{$col}) and
push (@input_err, "$col (Too long. Max length: $db_lengths{$col})");
if ($db_sort{$col} eq "date") {
push (@input_err, "$col (Invalid date format)") unless &date_to_unix($in{$col});
}
if ($col eq 'FieldName') {
if (($in{$col} < .25) or ($in{$col} > 24)) {
push(@input_err,"$col (not within range)");
}
unless ($in{$col}*100/25 == int($in{$col}*100/25)) {
push(@input_err,"$col (incorrect value)");
}
}
}
}
if ($#input_err+1 > 0) { # since there are errors, let's build
foreach $err (@input_err) { # a string listing the errors
$errstr .= "<li>$err"; # and return it.
}
return "<ul>$errstr</ul>";
}
else {
return "ok"; # no errors, return ok.
}
}
Notice that you will need to change FieldName to match the name of your field.<BR>
If you have already made changes to sub validate_record for some other reason you will need to compare above with
your current sub and make the appropriate changes.
Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/