Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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
 
Old September 1st, 2004, 10:57 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
Default validating date of birth in asp

I have created table date of birth. I am using sql server 2000
When I hit submit all the controls in txt boxes are cleared.

I type in suppose "asdefer" instead of 01/02/1970. When i hit "save" button it gives me mismatch error. I dont understand why and how I can solve this problem. In my sql server date of birth is 1970-08-02 format. In my asp page when I try to type in asdfg. it gives me mismatch error. How will I solve this problem. Thanks I will appreciate your help.

 
Old September 1st, 2004, 11:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

I don't understand the problem.... shouldn't you get an error if you type in asdfg into a textbox?????????

Brian
 
Old September 1st, 2004, 12:30 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 Well I should get an error, I guess because in the database
the date of bith format is 1970-02-05. When I type "acdg"in textbox. There is a mismatch. I dont know how when user enters acdg in textbox inform the user that he has typed wrong. He has to type valid birthdate. I hope you understand my question.
Thanks
shoakat

 
Old September 1st, 2004, 11:08 PM
Authorized User
 
Join Date: Aug 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sinapra Send a message via MSN to sinapra Send a message via Yahoo to sinapra
Default

He is trying to say that the entered format should not be allowed, i mean if ny user enters abcd, it should return some valid error message saying invalid entry kinda. He should be allowed to enter the DOB format in the specified format, I have a suggestion, why dont you put some text besides the text box indicating the Format of the DOB to the end users, say "Enter this format yyyy-mm-dd". This would help.
Another way is to put multiple select option where in any user will get three list boxes, one yyyy, second mm and the third dd.
Third option is, you can write Javascript code to check the correct entry. I hope that helps.

Regards

sinapra
 
Old September 2nd, 2004, 08:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

If you pass the date to a local variable, then with this variable remove the / or - in the date. use the IsNumeric function to check to see if it is a number. If not a valid number, there are unapproved textual characters in a date. Then you could say that there were text in the date.

You also have to count into the fact that what if you want the date in yyyy-mm-dd, and someone enters in 20004-30-8. That would be an incorrect date. With dates you would need to have a more detailed way of checking. You could also use Regular Expressions; they are pretty powerful.

Brian
 
Old September 2nd, 2004, 10:09 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can any body write the code for validating year,month and date without
Validate before it is send to the server.

I am also validating the the firstName and lastName, to see whether the user has enterd the first and second name. If not Validate before it is send to the server. My code for this is as follows but it requires something more
<script language = javascript>
        function C(){
        var FirstName = (document.thisForm.txtFName.value);
        var LastName =(document.thisForm.txtLName.value);
        if (FirstName=="" ||LastName=="")
        alert(" You have not entered the Last and FirstName");
       }

      </script>


 
Old September 2nd, 2004, 05:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Take a look at this. There are a lot of such code on the net for validation.

Date Validation

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old September 3rd, 2004, 12:18 AM
Authorized User
 
Join Date: Aug 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sinapra Send a message via MSN to sinapra Send a message via Yahoo to sinapra
Default

I am sure that would help Shoakat, the link suggested by Vijay, else he can build his own in ASP as suggested by brian since its good to have valid entry else it would bring some problems in date calculations.

Regards

sinapra





Similar Threads
Thread Thread Starter Forum Replies Last Post
Validating date abhishekkashyap27 Javascript How-To 2 May 5th, 2008 06:46 AM
Code for date of Birth.... aaronabdiel Visual Studio 2005 1 January 2nd, 2008 03:25 AM
Birth Date listings xp_mahesh JSP Basics 0 June 2nd, 2006 12:57 AM
Validation for Date of Birth crmpicco Javascript How-To 2 June 30th, 2005 08:13 AM
Date of birth question satts Access 10 February 24th, 2005 11:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.