Validate 2 digits after decimal point?


I am wondering what is the best approach to be able to validate a numeric field with 2 digits after the decimal point.
Does anyone have a small snippet of code.
I can't use the inbuilt validator controls of, as the textboxes would be generated on the fly.
9/13/2004 5:07:44 PM 93655 articles. 5 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 6

You can add validator controls on the fly, same as any other control.
Jared Livingston - Livingston Family Website

Test/Demo site -
9/13/2004 5:09:39 PM

Thanks for the speedy reply.
I am just trying to write this function, to which I pass the name of the textbox, the validation type such as string, number, maxlength, digits(if any) and then go ahead and validate them.
I would like to know what would be the best way.
9/13/2004 5:15:27 PM
Unless you have a specific reson for not validating on the cient, you should do your validating on the client.  So, you could still create a function, but you could have the function create validation control:

Private Function CreateValidator(ByVal myControl As Control, ByVal strValidateOrCompare As String, Optional ByVal myValidationDataType As ValidationDataType = ValidationDataType.String, Optional ByVal myValidationCompareOperator As ValidationCompareOperator = ValidationCompareOperator.Equal, Optional ByVal intMaxLength As Integer = 100, Optional ByVal intDigits As Integer = 2) As CompareValidator
Dim myCompareValidator As New CompareValidator
With myCompareValidator
If strValidateOrCompare = "Validate" Then
.ControlToValidate = myControl.ID.ToString
Else 'strValidateOrCompare = "Compare"
.ControlToCompare = myControl.ID.ToString
End If
.ErrorMessage = "Please enter a valid " & myValidationDataType.ToString & "."
.Type = myValidationDataType
.Operator = myValidationCompareOperator
End With
Return myCompareValidator
End Function

Then, as you create each of your textboxes dynamically, you could add a validation control:

Page.Controls.Add(CreateValidator([textbox control], "Compare", ValidationDataType.Date, ValidationCompareOperator.DataTypeCheck))

This is off-the-cuff, hope it works...

Jared Livingston - Livingston Family Website

Test/Demo site -
9/13/2004 5:59:57 PM

I will definately work on this.
Thanks for pointing me in the right direction.
9/13/2004 8:07:02 PM

Similar Artilces:

How to validate a decimal value with 2 digits after decimal point (de decimal point is a comma)
  I am a newbee, I have a Textbox where de user must write the price of an object. How can I validate de data entry in the Textbox (it must be a valid decimal with 2 digits after decimal point), and my pages are in  Portuguese so the decimal point to be accepted must be a comma   thanks  well you can do something like followig:  suppose TextBox1.Text = 123456,789 then you can say if(TextBox1.Text.Contains(",") ) {     int index1 = TextBox1.Text.IndexOf(",") +1;     int index2 = TextBox1.Text.IndexOf(...

DataWindow.NET and Web Forms #2
Hi, is it possible to develop web forms and use DataWindow.NET 1.0 ? If not in this version, when will it be possible? In what version ? And when will it be released ? A beta for Web Form capability is schedule for the middle to end of November. On 6 Oct 2004 02:42:05 -0700, Nuno Costa wrote: >Hi, > >is it possible to develop web forms and use DataWindow.NET >1.0 ? > >If not in this version, when will it be possible? In what >version ? And when will it be released ? Version 1.0 only supports Windows Forms applications. Version 1.5 will add suppo...

2 Button web form and validation
Ok. Heres the basic scenario, I have a search at the top of the page and a sumbit at the bottom. If the search is clicked the validation controls should fire for the search textbox only and if the submit clicked it should validate for everything but the search textbox. Any Idea how this can happen?   Thanks PS. Sorry if this a repost I've been getting forum errors.   Use all custom validators to perform this logic; ValidationGroups will be a feature in .NET 2.0 that will allow this; but for now, you would need to use custom val...

Implementing .Net Form into an web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

.Net 2.0 Web application using is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one web application using which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

Web Forms ( Having 2 forms )
Hey programmers. I would like to know how do I handle if a page has 2 forms? It does not allow 2 forms. So how do I overcome this problem ? Because in that page itself, I will have Login and Register together. So there are 2 forms. And if validation occurs. It will not work because it suppose to validate Login and not Registration fields. Thank You. Hey, Create a login user control or custom control that handles logging into the application. BrianBrian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your...

Access .Net 2.0 Application from .Net 2.0 Web Site
I need to populate a specific form in a .Net desktop application from a .net web application.  Is there an easy way to go about this? Hi, Based on my understanding, you want to start an executable application from your ASP.NET websit, right? We can invoke Process.Start method ( to launch an executable application from ASP.NET application. Note: Please keep in mind, the ASP.NET application is running on the server, so it will start the executable application that exists in the server.   I look...

Web form SaveAs XML decimal point
This is a multipart message in MIME format. --=_alternative 0029B2CEC12574C0_= Content-Type: text/plain; charset="US-ASCII" If I perform SaveAs in XML format and column is not displayed in datawindow decimal point is "," and ImportFile corrupts this number because it supposes probably ".". If column is displayed in dw it is ok (I put this column to report and erase option visible). Is there some other trick ? --=_alternative 0029B2CEC12574C0_= Content-Type: text/html; charset="US-ASCII" <br><font size=2 face="sans-serif&q...

Form validation problems in .NET 2.0
Hi,   I am creating my first .NET 2.0 form, and I need to do form validation.  I have several required field validators and some required expression validators for various form fields.    What I'm having trouble with is that I have 3 fields....First Name, Last Name and Institution Name.  Essentially, I want to require the user to either enter the Company Name or his/her First AND Last Name.  I couldn't figure out how to get 1 Validator to work for 3 different string fields.   I've tried several different ways to perform this validation and while the ...

web.config problems when upgrading from .NET 2.0 Beta to .NET 2.0 release version
We uninstalled .NET 2.0 Beta and replaced it with .NET 2.0 release version.  And it messed everything up.  All applications now give weird errors indicating the lack of web.config files, despite the fact that they already have web.config files in place.  For example, the following error occurs even though the web.config file has <customErrors="Off">: Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for securit...

How to validate controls on a .NET 2.0 Web user Control
Hi Guys, (ASP.NET 2.0 / C#) I've looked thorugh every post on validating web user controls (and know about Pter Blum's Professional Validation and More package) - but can't seem to get my head around whre to start. I have a web user control, called wucICL.ascx on a we page called AddEditInvestment.aspx.  I would like to validate a couple of DropDownLists (ddlAccounts and ddlContacts) when the Insert and Update buttons are clicked on the AddEdit Investment page. The other controls on the AddEditInvestments page belong to a validation group called All Validators and the DropDownL...

Web Matrix and .NET 2 #2
Hi, Last evening I modified the three config files in the Web Matrix folder (WM, Web Server and Class Browser) to target the .NET Framework beta 2. And it works, the WM app launches correctly and everything is cool ! So I tested some job done with .NET 1 and .NET 1.1, and it works too ! Web Matrix seems to be ready for the future ! Jim Hi Jim, Interesting! (Honestly, I did something like that when I was playing with WM and .NET Fx v1.2 some times ago..) WM is nifty and foundamental to VS (and the Express family) 2005, while I'd prefer VWD now, as it have IntelliSense an...

form validation working intermitently .NET Framework Version:2.0.50727.3053
I have created a web form that validates all textbox controls to prohibit the user from submitting a single quote (and other special characters). I have recently been told by our marketing department that some users have experienced an error when submitting the form. The error is below: Server Error in '/' Application. Syntax error (missing operator) in query expression ''Rarely for manual turbine moves in the field.  We usually run the models though instead of using the hard maps. I guess what I'm trying to say is it's not the map we want but the...

windows forms in vb .net into web forms
we are creating a database driven website as part of our project. currently we have forms connecting to the database created in visual basic. these windows forms we need to convert into web forms which are asp .net compatible. can u give me an answer or show me a way. Hi, because of the difference in nature between web and win applications you'll need to reimplement at least the UI part. If you have a multitiered application in which the busines logic and data access are in different parts/assemblies you can reuse them. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Wor...

Web resources about - Validate 2 digits after decimal point? -

Credit Card Validate on the App Store on iTunes
Get Credit Card Validate on the App Store. See screenshots and ratings, and read customer reviews.

Who Is Going to Shoot Obama? Paul Broun Chuckles, Validates Question - YouTube
Republican Congressman from George Paul Broun chuckles and does not even come close to denouncing a question asked by a constituent at a town ...

PM says MH370 debris find 'validates search'
Experts say recovered MH370 debris is consistent the area being searched in the southern Indian Ocean.

Spain's domination of England validates the Socceroos' search for identity
It is incredible to think that with all the billions of dollars of resources in the English game, their solitary success remains almost 50 years ...

Fracking report validates environmental concerns in N.W.T.
... Kenyon of the Pembina Institute. A director of the Pembina Institute in Edmonton says a new report on the risks of shale gas development validates ...

【medical-news】Study First to Validate That Singing Can Help People Learn a Foreign Language - 医药生命科学动态跟踪 ...
只是新闻而已Fernanda Ferreira’s family emigrated from Portugal to Canada when she was very young. There, like most Canadian children, she learned French ...

Supreme court validates private loans for rightful purposes
Supreme court validates private loans for rightful purposes

IXIA : Selected by China Network World to Validate High-Performance Cisco ...
IXIA : Selected by China Network World to Validate High-Performance Cisco ... 4-traders (press release) BEIJING - June 25, 2013 - Ixia (Nasdaq: ...

Apple Watch uses constant skin contact to validate Apple Pay purchases
... will the device make sure payments via Apple Pay are secure? Both the iPhone 6 and iPhone 6 Plus have the convenient Touch ID sensor to validate ...

Like You Really Need To Validate Your Social Media Presence….
How many Fortune 500 companies are blogging and using social media, and what can law firms learn from them?

Resources last updated: 1/21/2016 6:44:52 PM