Hi friends,
Please send me sample code for Validation for Percentage Edit field in blackberry. Like it will accept 1 to 100 and also 00.00 format
thanq
Hi friends,
Please send me sample code for Validation for Percentage Edit field in blackberry. Like it will accept 1 to 100 and also 00.00 format
thanq
final EditField editField = new EditField(EditField.FILTER_REAL_NUMERIC);
editField.setFilter(new TextFilter(){
public char convert(char c, int status) {
if (!validate(c))
return 0;
return c;
}
public boolean validate(char c) {
boolean isValid = false;
try {
String text = editField.getText();
double per = Double.parseDouble(text + c);
if (text.length()<=4&&per < 100 && per >= 0) {
isValid = true;
}
} catch (NumberFormatException e) {
isValid = false;
}
return isValid;
}
});