This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

submit blank fields

 
soumya kalla
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a login screen, when a user submits a blank page without entering a username and password, it should show an error message. What methods should I use to check that the fields are blank when submitted?

Soumya
 
Campbell Ritchie
Sheriff
Pie
Posts: 47258
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What sort of object are you using for your input? A JTextField? If you are checking the input with the getText() methods, you get a String. There are methods for checking the length of Strings, so you can send out an error message if the length comes to zero.

There are other possibilities.

CR
 
prasanna kanth
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi soumya Kala,

If ur using with JTextfield, the below snippet will work fine,
first u get the value and trim it then find the length, if it equals to zero prompt the message to the user the field can't be balnk.

if u use only length, the user may give empty space so, use with trim


Hope! This snippet will help u
PrasannA
[ June 08, 2006: Message edited by: prasanna kanth ]
 
soumya kalla
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou! I used the lengths and tried the application. It worked.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic