You just need to pass the password string in following method.........
public boolean containAlphanumeric(final String str) {
byte counter = 0;
boolean checkdigit = false, checkchar = false;
for (int i = 0; i < str.length() && counter < 2; i++) {
// If we find a non-digit character we return false.
if (!checkdigit && Character.isDigit(str.charAt(i))) {
checkdigit = true;
counter++;
}
String a = String.valueOf(str.charAt(i));
if (!checkchar && a.matches("[a-zA-Z]*")) {
checkchar = true;
counter++;
}
}
if (checkdigit && checkchar) {
return true;
}
return false;
}
public boolean containAlphanumeric(final String str) {
byte counter = 0;
boolean checkdigit = false, checkchar = false;
for (int i = 0; i < str.length() && counter < 2; i++) {
// If we find a non-digit character we return false.
if (!checkdigit && Character.isDigit(str.charAt(i))) {
checkdigit = true;
counter++;
}
String a = String.valueOf(str.charAt(i));
if (!checkchar && a.matches("[a-zA-Z]*")) {
checkchar = true;
counter++;
}
}
if (checkdigit && checkchar) {
return true;
}
return false;
}
owesome Shukla ji , this post help me in my project.
ReplyDelete