473,378 Members | 1,671 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,378 software developers and data experts.

Validation of a Date

Is there any way of using a validation control in c#.Net which finds out if
the date provided in a textbox is equal to or greater than the current date.
Does anyone know how to do this. Or does anyone know how to do this using c#
code.

Thanks for any help anyone is able to give me.
Nov 16 '05 #1
5 6190
On Tue, 16 Nov 2004 07:18:02 -0800, "Stephen"
<St*****@discussions.microsoft.com> wrote:
Is there any way of using a validation control in c#.Net which finds out if
the date provided in a textbox is equal to or greater than the current date.
Does anyone know how to do this. Or does anyone know how to do this using c#
code.

Thanks for any help anyone is able to give me.


Simply compare the ticks of the dates.

if (today.ticks >= Convert.ToDateTime(textBox.Text).Ticks)
Nov 16 '05 #2
Hi,

Is this a web or a win app?

if in win you can use Validating or LostFocus to make the check tht you
need. first convert the string to a datetime and then compare it with Today.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Stephen" <St*****@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...
Is there any way of using a validation control in c#.Net which finds out
if
the date provided in a textbox is equal to or greater than the current
date.
Does anyone know how to do this. Or does anyone know how to do this using
c#
code.

Thanks for any help anyone is able to give me.

Nov 16 '05 #3
I tried this but it doesn't seem to work have you any idea why

function DateCompatre(sender, args))
{
if(today.ticks >= Convert.ToDateTime(document.WebForm2.txtDate.Text) .Ticks)
{
args.IsValid = true;
return;
}
args.IsValid = false;

}

"Arne Schittenhelm" wrote:
On Tue, 16 Nov 2004 07:18:02 -0800, "Stephen"
<St*****@discussions.microsoft.com> wrote:
Is there any way of using a validation control in c#.Net which finds out if
the date provided in a textbox is equal to or greater than the current date.
Does anyone know how to do this. Or does anyone know how to do this using c#
code.

Thanks for any help anyone is able to give me.


Simply compare the ticks of the dates.

if (today.ticks >= Convert.ToDateTime(textBox.Text).Ticks)

Nov 16 '05 #4
Stephen wrote:
Is there any way of using a validation control in c#.Net which finds
out if the date provided in a textbox is equal to or greater than the
current date. Does anyone know how to do this. Or does anyone know
how to do this using c# code.

Thanks for any help anyone is able to give me.


If this is a WebApp, there is a CompareValidator. Set the Type to "Date",
the Operator to "GreaterThanEqual" and the ValueToCompare to
the current date.
Now if it was specified how the date format was handled, you could
almost use it (ddmmyyyy? mmddyyyy? yyyymmdd?)

Hans Kesting
Nov 16 '05 #5
Stephen,

Arne was refering to server side code (c#), not client side custom
validation (javascript).

Presumbly your saving details or updating somewhere (on click of an OK
button for example)... This would be the place to put Arne's if statement.

Daniel.

"Stephen" <St*****@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.com...
I tried this but it doesn't seem to work have you any idea why

function DateCompatre(sender, args))
{
if(today.ticks >=
Convert.ToDateTime(document.WebForm2.txtDate.Text) .Ticks)
{
args.IsValid = true;
return;
}
args.IsValid = false;

}

"Arne Schittenhelm" wrote:
On Tue, 16 Nov 2004 07:18:02 -0800, "Stephen"
<St*****@discussions.microsoft.com> wrote:
>Is there any way of using a validation control in c#.Net which finds out
>if
>the date provided in a textbox is equal to or greater than the current
>date.
>Does anyone know how to do this. Or does anyone know how to do this
>using c#
>code.
>
>Thanks for any help anyone is able to give me.


Simply compare the ticks of the dates.

if (today.ticks >= Convert.ToDateTime(textBox.Text).Ticks)

Nov 16 '05 #6

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

Similar topics

21
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
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...
0
by: Brian Conway | last post by:
I am having some validation and insertion problems. I am using a date picker that takes the selected date and puts it to ("dd-MMM-yyyy") format, as this was the only format that Oracle would...
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...
7
by: Paul | last post by:
Hi, I have a form where a user is required to enter a start date and an end date. Both are required and must between a specific date range (e.g. 01/01/1900 and 01/01/2099) and the end date...
4
by: Fraggle | last post by:
Hi, I want to validate a text box, The user can leave it blank, or fill it in. If they fill it in then it must be a date within a certain range. How can I achieve this? Thank you very much
6
by: Stephen | last post by:
Hi, the validation controls dont work on Netscape or Mozilla and only on Internet Explorer why? How do i correct this problem? Thanks
5
by: JIM.H. | last post by:
Hello, I have this validation expression: ^(?:(?:0?|1)|(?:0?|11)(?!\/31)|(?:0?2)(?:(?!\/3|\/29\/(?:(?:0||)00|(?:\d{2}(?:0||))))))\/(?:0?||3)\/\d{4}$ This is supposed to match MM/DD/YYYY it is...
12
by: Diego | last post by:
Can I validate (possibly with a compare validator) a Date entered by the user based upon his regional settings? I.e. if a user is american the format would be mm/dd/yyyy, if brittish dd/mm/yyyy...
12
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.