Monday, May 24, 2010

A String contain 821560888v.I want to validate this String every time a user enter a similar type-java coding?

that is 821560888 can be change.but i want to validate this 9 digits whether they are int not any other data type.i need java coding.

A String contain 821560888v.I want to validate this String every time a user enter a similar type-java coding?
To validate text input converted to a int try this:





try {


String s = new JTextField().getText(); // The user enters text in the text field


int value = Integer.parseInt(s);


}


catch(NumberFormatException ex) { // Invalid input, not a number


ex.printStackTrace();


}





Hope this helps


No comments:

Post a Comment