Gossamer Forum
Home : Products : DBMan : Customization :

remove all but digits from data entry?

Quote Reply
remove all but digits from data entry?
$rec{'listprice'} =~ tr/0-9.//cd;

I believe this should do it but where can I put it. Perhaps in join_encode something to the effect of:
if('thisisthecorrectfield(listprice)'){
$tmp=~ tr/0-9.//cd;#remove all but digits
}
The question is how do I identify the correct field. What should the if statement look like? I'm afraid my perl knowledge is not sufficient to allow me to figure this out any help would be appreciated.

Mike

[This message has been edited by mike1 (edited June 06, 1999).]
Quote Reply
Re: remove all but digits from data entry? In reply to
Your syntax is fine and will work. What is it that you want to do, though? Do you want to take out all but digits before a record is added to the database? If so, you would probably want to put it in sub validate records in the db.cgi script.

You would do something like this -- adding the bolded lines below:

Code:
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.
if ($col eq "listprice") {
$in{'listprice'} =~ tr/0-9.//cd;
}

}


------------------
JPD





Quote Reply
Re: remove all but digits from data entry? In reply to
Thanks JP that is exactly what I wanted to do. I also found another posting that led me to believe that I could put the code $in{'listprice'} =~ tr/0-9.//cd;
just before the validate routine is called in the add_record sub. Would this work also. Don't bother answering I will try it fo myself. Thanks again.

Mike