Results 1 to 10 of 10
Thread: TextField Validation
- 06-28-2008, 07:29 AM #1
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 06-28-2008, 07:53 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Try something like this,
Java Code:String temp = txtField.getText(); try { int val = Integer.parseInt(temp); } catch(NumberFormatException e) { System.out.println("Invalid"); }
- 06-28-2008, 10:12 AM #3
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 06-28-2008, 10:16 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
In that sense try to make a pattern and validate. Or in simple way, validate each number separating with the dot. Since you are talking about IPs, best thing would be patterns.
- 06-28-2008, 10:22 AM #5
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 06-28-2008, 10:24 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 06-28-2008, 05:37 PM #7
One more way is u can trim the IP address for "." and then do a Integer.parseInt() for each part.
To finish sooner, take your own time....
Nivedithaaaa
- 06-29-2008, 05:34 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
-
- 06-29-2008, 06:28 AM #10
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I don't think he want to read that a long material. ;)
Similar Threads
-
form validation
By abhiN in forum New To JavaReplies: 0Last Post: 03-07-2008, 07:04 AM -
Swing Validation
By ppayal in forum AWT / SwingReplies: 0Last Post: 02-09-2008, 09:00 AM -
Swing validation
By ppayal in forum New To JavaReplies: 0Last Post: 02-09-2008, 08:59 AM -
java validation?
By lockmac in forum New To JavaReplies: 3Last Post: 08-14-2007, 04:34 PM -
javascript validation
By yuchuang in forum New To JavaReplies: 5Last Post: 05-14-2007, 03:38 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks