CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 How to verify the amount format prior sending the form for processing

Print topic Send  topic

Author Message
sjenny

Posts: 5
Posted: 07/27/2004, 9:34 AM

Hello,

I would like to know if someone can point me to the code to validate an amount fields.

The amount must be for exemple: 1234.89 without any thousand separation and with a point to separate the cents from the dollars.

The code I'm looking for is to verify if the format is correct
The MySQL database field wich will save the value is "Double (10,2)"

Thanks a lot
View profile  Send private message
DaveRexel

Posts: 50
Posted: 07/27/2004, 10:00 AM

::
The Number Format Property should achieve this without manual coding

http://docs.codecharge.com/studio/html/Components/Prope...Format.html?toc

this would be an example mask ####.00
_________________
/Dave
RexDesign CodeCharge Studio Tutorials
http://rexdesign.com/ccs/
View profile  Send private message
sjenny

Posts: 5
Posted: 07/27/2004, 11:37 AM

Thanks dave,
I already use a mask, but the user just write something differents

I really need to verify the format once the form is sent

I can call a fonction (verify_amountformat) but I don't know to write the fonction content to verify that the amount is given in the right format, I tried with [0-9].[0-9] but this still accept a comma "," in place of the "." to separate the cents !

Looking forward to more help, thanks
View profile  Send private message
DaveRexel

Posts: 50
Posted: 07/27/2004, 12:01 PM

::
Could you please post the contents of the function verify_amountformat so it can be adapted
_________________
/Dave
RexDesign CodeCharge Studio Tutorials
http://rexdesign.com/ccs/
View profile  Send private message
sjenny

Posts: 5
Posted: 07/27/2004, 12:06 PM

Here is the fonction,

the second one is to check the username and is working fine.

function verify_amountformat($amount){
return !(bool)ereg("[0-9.]", $amount);
}

function verify_username($username){
return !(bool)ereg("^[a-zA-Z0-9]+$", $username);
}


thanks
View profile  Send private message
sjenny

Posts: 5
Posted: 07/27/2004, 12:11 PM

I got it...

the ^ at the begin and the +$ at the end are necessary, I was first thinking those are some more allowed caracters.

the right fonction is:

function verify_amountformat($amount){
return !(bool)ereg("^[0-9.]+$", $amount);
}

Sorry for disturbing so much for something that was so simple after hours of searching....

thanks Dave
View profile  Send private message
DaveRexel

Posts: 50
Posted: 07/27/2004, 12:31 PM

::
Very happy that it worked out fine :)
_________________
/Dave
RexDesign CodeCharge Studio Tutorials
http://rexdesign.com/ccs/
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.