• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Validate a JTextField to Accept only Strings-NOT any int input!  RSS feed

 
Behrouz Hosseini
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys
Could you please let me know how I can validate a JTextFile to accept only string inputs NOT any integer.How can I use any exception class for this?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on this forum's main page there is an FAQ link which has the opposite of your requirement (numbers only), modify to suit
 
Behrouz Hosseini
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Honestly I dont know how to modify it to read only string!
if (str != null && DIGITS.matcher(str).matches())
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
look up the Pattern class, it's all there
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!