.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Validate input has up to 2 decimal places

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :ASP.Net
I need to validate hours put into a textbox.  I want to allow hours to be from 0-24 and allow up to 2 decimal places. so it has to accept not 2.225 or 25I put a range validator that check that the value is from 0-24 but it doesn't check that there are 2 decimal places or less.  how do I do that?

View Complete Post

More Related Resource Links

Validate form input - Japanese


 I've searched for several hours and haven't come up with a reference - or even many discussions - of how to go about validating Japanese names, addresses, etc. When I lived in Japan websites, atm's etc. required such info to be entered with the roman alphabet but I've seen some websites that are allowing Kanji/Hiragana/Katakana. I haven't tested many of them for validation but one that I did test (after looking at the page source and discovering no client-side validation) allowed me to put this in the name field: J*=123*go^ Neat!

Any pointers/references? Thanks

validate date/time span and alow only time input

Hi, I have 2 small questions: 1. How can I  make a filed for input only time without date? 2. I need to make a date/time validation in form like: if(time between begin_date_field  and end_date_field) is not in intersection (time between begin_date_field  and end_date_field) of any item in list) Can I make this validation only using VisualStudio2010 or is there a simpler way? ( I need this for small list for managing reservations of conference rooms )

Validate (Javascript) if input date is within this range...


I'd like to validate if the inputed date is within this range:

3 weeks before today's date to 3 weeks after today's date 

The following Javascript code checks if the date is within either today's date or 2 weeks before:

var dateSystem = (dateToday.getMonth() + 1) + dtCh + dateToday.getDate() + dtCh + dateToday.getFullYear();
            var prev = new Date();
            //past date 14 dates before today
            prev.setDate(prev.getDate() - 14);
            var pastDate = (prev.getMonth() + 1) + dtCh + (prev.getDate()) + dtCh + prev.getFullYear();
            var time1 = new Date(dateSystem).getTime();
            dtStr = month + dtCh + day + dtCh + year;
            var dateuser = new Date(dtStr);
            var time2 = dateuser.getTime();
            if (time1 - time2 <= 1209600000 && time2 <= time1) {
                return true;
            } else {
                alert("Vaccines/Services date must be within this date range: " + pastDate + " to " + dateSystem);
                return false
            return true


I'm not sure how to modify. I actually got the code above from these forums.

Help is much appreciated!

sharepoint number field in list comes with decimal places in dispform


hello guys,

 the sharepoint number field in list comes with 2 decimal places in dispform, like

when I enter number like 12 on new form, when I open the dispform, it shows 12.00

I tried to keep the decimal places to 0  but it didn't work.

Do you guys know anything about this one. I don't want to make it a single line of text.

find amounts with more than 2 decimal places in a float type column

I was trying to use charindex but that didnt work.  Also what happens if i change the column to money data type? does it round or truncate?

convert value to 2 decimal places?



Hello, is there a way to convert the value to just 2 decimal places, I created the report in Reporting Services and it has quite a few digits to each value.  I looked at the table and found that the data type is {Float}.  Is there a way to convert the values to just 2 decimal places?..Thank You.

Round off Decimal to 2 places in jQuery


Hi everyone,

How come the following code does not work:



var t_o_t_a_l = parseFloat(total.toString()).toFixed(2);



labels show 1 or 0 decimal places



i have some labels on a page.

 some id like to show 1 decimal place, and others to show the nearest whole number.

how do i control the decimal places my labels show?


Edit/Display of Report/Properties/Parameters only 2 decimal places show need 4 decimal places


Does anyone know if there is a way to display 4 decimal places on an Overide Default of data type Float on the Report/Properties/Parameters page.  It accepts 4 decimals and that is what is used in report but when returning to this screen it only displays 2 decimals.

SSRS 2005

Validate a certain number of input tags


My users will add text to be translated.
Inside the text we would like to allow a certain number of tags.
Most of them will be simple formatting but some can be extended to cover reserved words etc.

Now we would like to validate user input to ensure correct entries.

The assumption is to use HTML like formatting tags like: <b>, <br/>, <ul>, <li>, etc.
Even definitions could probably be covered by HTML if using something like: <code>, <cite>, <dfn>
This means it is fully possible to limit tags to valid HTML if that helps.

My initial guess is that Regex is faster since we will only allow a very limited number of tags.
But that validation soon becomes very complex, especially if we allow nested tags which is very much preferred and even necessary for <ul> lists.

Is there maybe a XHTML validator that might be possible to use?

I saw that TinyMCE has a similar input validation, but I am not able to detect how they actually process and apply it.
I still would prefer C# based solution over javascript.

Using a CompareValidator to check input is a valid date

The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

JQuery Validate plugin to validate a ASP.NET Form

The first time I used the JQuery Validate plugin, it did not work at all, see JQuery Validate odd behaviour with the ASP.NET Script Manager for reason, but perseverance and stubbornness prevailed and I finally created my first JQuery validated ASP.NET Forms contact form.

Input Validation: Enforcing Complex Business Data Rules with WPF


Windows Presentation Foundation has a rich data binding system that includes flexible support for business data validation. We take a look at implementing some complex data input validation scenarios that include customized data errors for users.

Brian Noyes

MSDN Magazine June 2010

Going Places: Gesture Magic


Windows Mobile 6.5 is the first version of the OS to expose gesture support to developers. Marcus Perryman explains how five touch screen gestures are handled, detailing message routing, the physics engine and some handy tips and tricks.

Marcus Perryman

MSDN Magazine February 2010

Going Places: Enhancing Windows Touch Applications for Mobile Users


This article describes how to use the Windows Touch API and related APIs to enhance mobile application. The discussion focuses on general usability, object selection and implementing a natural user interface.

Gus Class

MSDN Magazine December 2009

Going Places: An Introduction to IPsec VPNs on Mobile Phones


Many commercial phone models, including Windows phones, come with a VPN client. This article covers some of the basics of the technology behind IKEv2 and MOBIKE and how to use them to create and manage a VPN for a mobile phone.

Ramon Arjona

MSDN Magazine September 2009

Going Places: Gaming In The Key Of Zune


Mike Calligaro shows you the basics of using XNA Game Studio 3.0 to write games for Zune.

Mike Calligaro

MSDN Magazine May 2009

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend