Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding validations to a form  RSS feed

 
Sandun Suranga Wijenayaka
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on a Add new user form and I have to enable the Save button after validating following.
*user name field must include some letters(either correct or wrong).
*password field and verify password field must include some letters(either correct or wrong).


 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a DocumentListener to be notified whenever text is added or removed from a text component.

Here is a flexible example that will enable/disable a button as text is added or removed from a list of text fields:



And quit cross posting: http://stackoverflow.com/questions/35509465/java-jtextfield-validation (link updated)

It is annoying to spend the time answering a question only to find out it may have already been answered. We don't have time to spend on questions like this.
 
Sandun Suranga Wijenayaka
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got an answer at http://stackoverflow.com/questions/35509465/java-jtextfield-validation?answertab=votes#tab-top
I'm new to programming forums and I'm still learning things right.
Sorry every one for cross posting the question.
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got an answer at..


What is wrong with this answer?

1) It was posted before the other answer
2) It is more flexible and more reusable than the other answer.

Again, did you even read this answer before deciding which solution to use?
 
Sandun Suranga Wijenayaka
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, this answer is much greater than the other answer, but some components of this answer gonna mess with me(implementing Interfaces, ArrayLists & List).
Therefore I accepted that answer. This week right we learn those stuff in the class. Therefore got the use of this one.
Thanks for everyone's contribution.

End of thread.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!