Results 1 to 3 of 3
  1. #1
    sgiri37 is offline Member
    Join Date
    Mar 2012
    Posts
    1
    Rep Power
    0

    Exclamation Accepting value for phone number field

    Hi All,

    i am Accepting the vale for phone number field like the code i below mentioned

    But when i am giving the telephone number like 8050234456 is showing the error like this

    The following error(s) must be corrected

    •Telephone Number should be Number format



    Is there any other way to parse so that i will not get this error.
    I identify the root cause as Integer.parseInt(value);here we exceed the Integer limit
    Is there any other way except the below logic .

    Thanks in Advance

    private String checkNumberFormat(String value, String fieldName) {
    String returnVal = "";
    try {
    if (value == null || value.trim().length() == 0) {
    returnVal = fieldName + " is required.";
    } else {
    Integer.parseInt(value);
    }
    } catch (Exception e) {
    returnVal = fieldName + " should be Number format";
    }
    return returnVal;
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Accepting value for phone number field

    Run this line of code:
    Java Code:
    System.out.println(Integer.MAX_VALUE);
    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,310
    Blog Entries
    7
    Rep Power
    20

    Default Re: Accepting value for phone number field

    Parse the String as a long value? Check if all characters are digits? (<--- hint, regexes will do fine here).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Random Phone number generator
    By elecleoalune in forum New To Java
    Replies: 15
    Last Post: 05-19-2014, 12:37 PM
  2. StringTokenizer phone number program
    By Erykah in forum New To Java
    Replies: 12
    Last Post: 11-22-2011, 07:16 AM
  3. Phone number stringtokenizer problem
    By jacques5309 in forum New To Java
    Replies: 10
    Last Post: 11-14-2011, 02:12 AM
  4. UK Phone Number regex validation?
    By ozzyman in forum New To Java
    Replies: 8
    Last Post: 04-12-2011, 09:15 AM
  5. Phone number Program ..
    By Sary in forum New To Java
    Replies: 9
    Last Post: 03-17-2010, 07:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •