473,387 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

validation on amount

Hi there,

I am using a form to let the user enter an amount.
This must be with zero OR with 2 decimals.
I'm using the comma for decimal seperator.
How can I check if the input is valid (ereg or preg_match?) and what is the
exact statement I will have to use?

Please help me with this.
Thank you.

Stefan.
Mar 28 '06 #1
1 1495
If you're data will look like '2,10' and you're exploding on the comma
(i.e. array( 0=>2,1=>10) ), it's quicker and easier to use intval() or
is_numeric() on each of the parts. If that doesn't suffice, what
exactly are your constraints (since validation is very important)?

2,00
0,00
1000000000000000000000000000000,00
9,99

Best/easiest way is to split the two values (decimal and whole number)
into separate form values.

Mar 29 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hernán Castelo | last post by:
should i to validate all the "Request"s calls like Request.FORM("...") and Request.Cookies("...") ???? if it is so, i have to see inside every "Input" elements like "Text" and even "Hidden"...
30
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
67
by: Scott Meyers | last post by:
I have a web site that, due to maintenance by several people, some of whom are fairly clueless about HTML and CSS, etc. (notably me), has gotten to the point where I'm pretty sure it's suffering...
0
by: RockyH | last post by:
Hello, I'm having a problem when trying to use the XmlReader.Create(nodeReader, settings) method to validate an XML document against a schema. The problem is that if there are multiple missing...
1
by: JB | last post by:
Having problems with this: schema is: <xs:schema xmlns="xsdPayment" targetNamespace="xsdPayment" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Payment" type="PAYMENT" />...
1
by: Dalan | last post by:
For some apparent reason I have been unable to structure a piece of code on the BeforeUpdate event on a form that has 3 fields which I need to set validation rules. I would appreciate anyone's...
2
by: Dnna | last post by:
I have a table which is bound to an Internet Explorer XML data island. I'm using ASP.NET's client-side validators for an input field in the table. The problem is that if the input fields are in...
3
by: Filippo | last post by:
Ciao! I've been developing my application for a while and after testing under Mozilla, I've noticed that validation controls are not rendered at all! Any ideas or/and suggestions? thanks, ...
3
by: nickhufc | last post by:
Hi, im doing a module at uni in which I have to make userforms and use VBA, ive never done VBA until a few days ago, getting on ok with it, but I was wondering how to validate the information in a...
5
by: maz77 | last post by:
I'm trying to develop a good validation for a date in C#; a valid date can be inserted in these formats: - dd/mm/yyyy - dd/mm/yyyy h24:m - mm/dd/yyyy - mm/dd/yyyy h12:m How can I proceed? Is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.