Hi,
I program in asp.net. I have a date in TextBox in format "dd/MM/yyyy".
I would like to validate if the date is realy correct.
I used RegularExpressionValidator with
ValidationExpression="[0-3][0-9]/[0-1][0-9]/[1-2][0-9][0-9][0-9]", but user
can write date "31/02/2000" and validator says that it is correct (everybody
know that Febuary has 28 or 29 days).
I was thinking of using RangeValidator with Type="Date". But how to told
RangeValidator, that date is in format "dd/MM/yyyy" ?
Maybe it is easier solution ?
I would like to have total secure validation method in client site..
Thanks for help 14 15078
<am*******@poczta.onet.plwrote in message
news:gf**********@news.onet.pl...
I program in ASP.NET. I have a date in TextBox in format "dd/MM/yyyy".
I would like to validate if the date is really correct.
Firstly, your date format is ambiguous. E.g. in that format, tomorrow's date
would appear as 12/11/2008. Some people will see that as 12 November but
others (e.g. our friends in US) will see it as 11 December 2008. You should
always display dates using a three-digit month.
Maybe it is easier solution ?
I would like to have total secure validation method in client site..
By far the easiest solution, and one which will never permit invalid dates,
is not to allow users to enter dates manually at all. Instead, use a date
picker.
There are dozens, maybe hundreds, of these available: http://www.google.co.uk/search?hl=en...icker%22&meta=
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...
<am*******@poczta.onet.plwrote in message
news:gf**********@news.onet.pl...
>I program in ASP.NET. I have a date in TextBox in format "dd/MM/yyyy". I would like to validate if the date is really correct.
Firstly, your date format is ambiguous. E.g. in that format, tomorrow's
date would appear as 12/11/2008. Some people will see that as 12 November
but others (e.g. our friends in US) will see it as 11 December 2008. You
should always display dates using a three-digit month.
[...]
But I know that my date is in format "dd/MM/yyyy". I did:
<asp:TextBox ID="txtDateFrom" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarDateFrom" runat="server"
TargetControlID="txtDateFrom"
Format="dd/MM/yyyy">
"imbirek8" <im******@op.plwrote in message
news:gf**********@news.onet.pl...
>>I program in ASP.NET. I have a date in TextBox in format "dd/MM/yyyy". I would like to validate if the date is really correct.
Firstly, your date format is ambiguous. E.g. in that format, tomorrow's date would appear as 12/11/2008. Some people will see that as 12 November but others (e.g. our friends in US) will see it as 11 December 2008. You should always display dates using a three-digit month.
[...]
But I know that my date is in format "dd/MM/yyyy".
Are you the only user of the system...?
--
Mark Rae
ASP.NET MVP http://www.markrae.net
Mark Rae [MVP] wrote:
"imbirek8" <im******@op.plwrote in message
news:gf**********@news.onet.pl...
>>>I program in ASP.NET. I have a date in TextBox in format "dd/MM/yyyy". I would like to validate if the date is really correct.
Firstly, your date format is ambiguous. E.g. in that format, tomorrow's date would appear as 12/11/2008. Some people will see that as 12 November but others (e.g. our friends in US) will see it as 11 December 2008. You should always display dates using a three-digit month.
[...] But I know that my date is in format "dd/MM/yyyy".
Are you the only user of the system...?
The trick of writing on the form in what format the date is to
be entered has been seen both on paper and on computers.
:-)
Arne
<am*******@poczta.onet.plwrote in message
news:gf**********@news.onet.pl...
I program in asp.net. I have a date in TextBox in format "dd/MM/yyyy".
I would like to validate if the date is realy correct.
I used RegularExpressionValidator with
ValidationExpression="[0-3][0-9]/[0-1][0-9]/[1-2][0-9][0-9][0-9]", but
user can write date "31/02/2000" and validator says that it is correct
(everybody know that Febuary has 28 or 29 days).
I was thinking of using RangeValidator with Type="Date". But how to told
RangeValidator, that date is in format "dd/MM/yyyy" ?
Maybe it is easier solution ?
I would like to have total secure validation method in client site..
You can use a CustomValidator, and write your own validation code in a
small routine in javascript. You will also want to replicate that code in C#
on the server side, to cover the case where the user bypasses validation on
the client side.
With a Textbox
Try DateTime.TryParse()
if its a good date returns true
example below
string sDate ="02/29/2007";
DateTime DateValue;
Console.WriteLine(DateTime.TryParse(sDate,out DateValue).ToString());
DaveL
<am*******@poczta.onet.plwrote in message
news:gf**********@news.onet.pl...
Hi,
I program in asp.net. I have a date in TextBox in format "dd/MM/yyyy".
I would like to validate if the date is realy correct.
I used RegularExpressionValidator with
ValidationExpression="[0-3][0-9]/[0-1][0-9]/[1-2][0-9][0-9][0-9]", but
user can write date "31/02/2000" and validator says that it is correct
(everybody know that Febuary has 28 or 29 days).
I was thinking of using RangeValidator with Type="Date". But how to told
RangeValidator, that date is in format "dd/MM/yyyy" ?
Maybe it is easier solution ?
I would like to have total secure validation method in client site..
Thanks for help
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:e$**************@TK2MSFTNGP03.phx.gbl...
[...]
Are you the only user of the system...?
No, but I thought that if I user code like this:
<asp:TextBox ID="txtDateFrom" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarDateFrom" runat="server"
TargetControlID="txtDateFrom"
Format="dd/MM/yyyy">
it doesn't mather globalizations and localizations settings in browser, am I
right ?
"DaveL" <dv*****@sbcglobal.netwrote in message
news:_F*****************@flpi149.ffdc.sbc.com...
[...]
Try DateTime.TryParse()
if its a good date returns true
example below
string sDate ="02/29/2007";
DateTime DateValue;
Console.WriteLine(DateTime.TryParse(sDate,out DateValue).ToString());
[...]
I user date in format "dd/MM/yyyy" not in format "MM/dd/yyyy". This method
doesn't work with this format.
"imbirek8" <im******@op.plwrote in message
news:gf**********@news.onet.pl...
>Are you the only user of the system...?
No, but I thought that if I use code like this:
<asp:TextBox ID="txtDateFrom" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarDateFrom" runat="server"
TargetControlID="txtDateFrom" Format="dd/MM/yyyy">
it doesn't mather globalizations and localizations settings in browser, am
I right ?
No you are not, though the fact that you are now using a calendar control is
a step in the right direction.
However, so long as you continue to use an ambiguous date format, your app
will always be open to ambiguity...
The fact that *you* know what date format you're using is completely
irrelevant - you can't expect your users to be telepathic...
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"imbirek8" <im******@op.plwrote in message
news:gf**********@news.onet.pl...
I user date in format "dd/MM/yyyy" not in format "MM/dd/yyyy". This
method doesn't work with this format.
Now that you're using a calendar control, and users cannot enter dates
manually, you no longer need to do any date format validation - that's the
whole point of using a date picker...
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote:
> Firstly, your date format is ambiguous. E.g. in that format, tomorrow's date would appear as 12/11/2008. Some people will see that as 12 November but others (e.g. our friends in US) will see it as 11 December 2008. You should always display dates using a three-digit month.
Do you mean "three-character month"? That is, "12/Nov/2008"? I have
certainly never seen an interface that used a 3-digit month.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
"Tim Roberts" <ti**@probo.comwrote in message
news:mu********************************@4ax.com...
>>Firstly, your date format is ambiguous. E.g. in that format, tomorrow's date would appear as 12/11/2008. Some people will see that as 12 November but others (e.g. our friends in US) will see it as 11 December 2008. You should always display dates using a three-digit month.
Do you mean "three-character month"? That is, "12/Nov/2008"?
Yes. Apologies for usage of incorrect terminology.
--
Mark Rae
ASP.NET MVP http://www.markrae.net
Tim Roberts wrote:
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote:
>Firstly, your date format is ambiguous. E.g. in that format, tomorrow's date would appear as 12/11/2008. Some people will see that as 12 November but others (e.g. our friends in US) will see it as 11 December 2008. You should always display dates using a three-digit month.
Do you mean "three-character month"? That is, "12/Nov/2008"? I have
certainly never seen an interface that used a 3-digit month.
It is used. As 12-Nov-2008 not 12/Nov/2008 though.
In contexts where readers can be both American and European it
is a good way to ensure that everybody reads it as the same
date.
Arne
Arne Vajhøj <ar**@vajhoej.dkwrote:
>Tim Roberts wrote:
>"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote:
>>Firstly, your date format is ambiguous. E.g. in that format, tomorrow's date would appear as 12/11/2008. Some people will see that as 12 November but others (e.g. our friends in US) will see it as 11 December 2008. You should always display dates using a three-digit month.
Do you mean "three-character month"? That is, "12/Nov/2008"? I have certainly never seen an interface that used a 3-digit month.
It is used. As 12-Nov-2008 not 12/Nov/2008 though.
That's not a three-digit month. That's a three-character month, as I said.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Erik R.N. |
last post by:
Hi
I have a ACCESS2002 table with a date-field in format "dd-mm-yyyy"
which I "export" to a txt-file ( ; and " " )
and upload the txt-file to a...
|
by: Ian |
last post by:
I would like to have some validation on a date field. The date format
is dd/mm which is used for our financial year end. I suppose I need
also...
|
by: Sabina |
last post by:
Hello,
How can I porting this code
to_date('" & Format(Date, "MM/DD/YYYY") & "','mm/dd/yyyy')
from VB to aspx?
SelectCommand="SELECT *...
|
by: kaw480 |
last post by:
I was wondering if there was a way to show when a page was updated, and have that date displayed on a page.
|
by: mgpsivan |
last post by:
Hi,
i have form in Asp.net(2003) in that i've to change the format of the date by the following statement
Format(Date.Today, "dd/mm/yyyy")
but...
|
by: nudrat |
last post by:
I have a form in ASP, where Date has to display in "dd/mm/yyyy" format. when I am saving that format into database its giving either error message or...
|
by: stainless |
last post by:
I know this is probably simple but I cannot find a method of
converting a date string into a format that matches the DatePicker
format in C#
eg...
|
by: maminx |
last post by:
Hello all, asking again
i want to convert format date from "YYYY-mm-dd" to "dd-mm-YYYY"
example from "2008-08-16" become format date like this...
|
by: JFKJr |
last post by:
Hello everyone, this one might be simple but driving me crazy!
Your help will be greatly appreciated.
Basically, I created a textbox bound to...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...
| |