 |
BOOK: Beginning ASP.NET 1.0  | This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

October 18th, 2004, 09:02 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Entering Date on web form
Hi, I have a web form, where I take in the user Date Of Birth (DOB) in a textbox in the form of mm/dd/yyyy.
However, if the user does not enter in the correct format user gets an error. This happens if the user enters "dd/mm/yyyy", "w", or any other letter. I add the DOB to my database on a function called AddUser. This is ran when I click the add button which runs the AddUser function.
I know that this isn't very hard, but I cannot get it to work!!
Please any help will be greatly appreciated.
Thanks in Advance,
Very frustrated!!
|
|

October 18th, 2004, 09:15 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hey,
You could use Regular expressions:
Imports System.Text.RegularExpressions
..
If (Regex.IsMatch(txtDOB.Text, "(1[0-2]|[1-9])/(3[0-1]|[1-2]0|[1-2]?[1-9])/[1-2][0-9]{3,}")) Then
'Valid
Else
'Invalid
End If
There are probably better Regular expressions.
Brian
|
|

October 18th, 2004, 09:16 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
I should also mention, that you won't be able to parse out users who enter the date:
3/10/2004
to actually mean October 3, 2004. It will see that as a valid date, because it is.
Brian
|
|

October 18th, 2004, 09:18 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hey brian,
Thanks for the fact post...could you explain regular expression or get me a link where I may read-up on this.
As I am still relativity new to the .NET world, I never read or seen regular expressions before.
Thanks again.
Mark
|
|

October 18th, 2004, 09:49 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How do you suggest I go about validating the textbox for a valid date?
Mark
|
|

October 19th, 2004, 12:08 PM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Brian,
I have it working now.
Mark
|
|
 |