if (firstName.equals("")) {
errors.put("firstName", "Please enter your first name");
firstName = "";
allOk = false;
} else {
String expression1 = "^[!,@,#,$,%,^,&,*,(,)]+$";
CharSequence inputStr1 = firstName;
Pattern pattern1 = Pattern.compile(expression1);
Matcher matcher1 = pattern1.matcher(inputStr1);
if (matcher1.matches()) {
allOk = true;
} else {
errors
.put("firstName",
"FirstName Should be Special Character");
firstName = "";
allOk = false;
}
}
How To Validate the Special Character?