-
Urgent! Help Please
Hello to all:
I am working on a registration form and I am not sure how to stucture the phone link. The instuctions that I have contain the following: This method should check that the first 3 digits of the phone are 412 or 724. If the first 3 digits of phone number are 412 or 724 then the phone label foreground should be set back to its original color. If the first 3 digits of the phone ar not 412 or 724, then the phone label foreground should be set to red.
So it seems that I need include the length for a 10digit number and also a plain interger for 412 and 724 . But not sure how to combine the two so the java computer will accept the 412 and 724 and then also accept the length of ten numbers. Any help welcome
-
Below is my code that work without errors but does not do what I want it to do?
private boolean checkHomePhone ()
{
try
{
String phone = textHomePhone.getText();
int homephone = Integer.parseInt(phone);
if (phone.equals("412"))
{
labelHomePhone.setForeground(Color.ORANGE); //address is correct
return true;
}
if (textHomePhone.getText().length() == 10)
{
labelHomePhone.setForeground(Color.ORANGE); //address is correct
return true;
}
else
{
labelHomePhone.setForeground(Color.RED); //address is correct
return false;
}
Similar Threads
-
By samtron in forum ASP.NET
Replies: 5
Last Post: 02-21-2006, 12:46 AM
-
By Lawrence Kang in forum Java
Replies: 1
Last Post: 01-20-2006, 11:17 AM
-
By Ravikant Ninave in forum VB Classic
Replies: 0
Last Post: 08-31-2001, 05:27 AM
-
By precious in forum Enterprise
Replies: 2
Last Post: 06-23-2001, 02:34 PM
-
By ramanand in forum Java
Replies: 0
Last Post: 10-17-2000, 05:34 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks