freelanceprogrammers.org Forum Index » Java
empty textfield value
Joined: 31 Jan 2002
Posts: 26
empty textfield value
What is the value returned by surname.getText()
of a textfield, if someone doesn`t enter any value?
How do you test for it?<br><br>I tried:<br>if
(surname.getText() == "")<br>and<br>if (surname.getText() ==
null)<br>but neither seems to work - or am I doing something
else wrong?<br><br>Thanks.
Joined: 10 Feb 2002
Posts: 15
empty textfield value
Try using the equals() method like so:<br><br>if
(surname.getText().trim().equals(""))
Joined: 31 Jan 2002
Posts: 39
empty textfield value
If surname has not been initialized it will be
null. You will experience a NullPointerException
whenever you try to call one of surname`s methods in this
situation. <br><br>Test first for the null.<br>if (surname
!= null) {// do work here}<br><br>My 2
cents<br>epenak
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







