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

got a question here..

if a user inputs a date in the text field witht the wrong format..how i can i make an error message that will catch the error that the input date format is wrong?
please answer me..asap
Mar 23 '07 #1
2 1081
r035198x
13,262 8TB
if a user inputs a date in the text field witht the wrong format..how i can i make an error message that will catch the error that the input date format is wrong?
please answer me..asap
You check the entered data against the format(s) that you allow and show a pop if it's wrong. Where are you getting problems?
Mar 23 '07 #2
if a user inputs a date in the text field witht the wrong format..how i can i make an error message that will catch the error that the input date format is wrong?
please answer me..asap
It depends. How are you going to be passing the validations. Assuming it's from a jsp, this validation could be done via javascript at the user interface - webpage.

Else, if u are to pass it strait to java, just surround the Date instantating line with a try catch block. After this you juss have to work on the program flow and java will catch the exception for you. It's up to you to ignore the date creation line or prompt the user for a valid date from there. For example -:
Expand|Select|Wrap|Line Numbers
  1. //BALALALALA CODE
  2. // CODE TO RECEIVE THE USER date INPUT
  3. String dateReceived = req.getParameter("myDate");
  4. java.sql.Date progDate = null;
  5. try{
  6.      progDate  = java.sql.Date.valueOf(dateReceived);
  7. }catch(DateFormatException dtfe){
  8. //code for program flow after an invalid date is receved
  9. }
  10.  
If your date format is more persnalised and not the default ones of sql.Date, or util.Date, I suggest that you visit Regular Expressons to do the validation checks then.
Mar 23 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tony Johansson | last post by:
Hello! I'm reading a book about C++ and there is something that I don't understand so I ask you. I have marked the section from the book that is of intertest by tagging it with BOOK START HERE...
11
by: NC Tim | last post by:
Hello, I think the question i have is fairly straightforward, but I can't seem to replicate the old SAS frequency procedure when I try to accomplish this in MS Access. anyway, i have about 10...
6
by: NC Tim | last post by:
Hello, I think the question i have is fairly straightforward, but I can't seem to replicate the old SAS frequency procedure when I try to accomplish this in MS Access. anyway, i have about 10...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
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:
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.