• Post Reply Bookmark Topic Watch Topic
  • New Topic

Single JTextField Validation  RSS feed

 
Jain Neeraj
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends,
I've a JTextField that allows user to enter the following
- the date and
- any integer (+ve or -ve)
the problem is to have them both on a single JTextField
Any hints on this?
Thanks
N.
 
tormod eriksen
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what exactly is the problem?
 
Jain Neeraj
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well i'm a bit confused abt how do i allow for both a valid date and an integer input (i know applying them seperately) on one TextField.
-N.
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
first I would test, if the user entered an int value. If not, then test for a date. If both tests are not true, then the user probably was wrong.
I don't know, what your reason for that is, but separating both (int and date) would be better. So the user won't be confused.
What you could also do, you could link the JTextField with two unselected RadioButtons (int and date), where the user has to select one before he can enter a value. That might look not bad.
Hope that helps you a bit!
Rene
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!