Validation for SpecialCharacter
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?
Re: Validation for SpecialCharacter
Perhaps elaborate more on your requirements...maybe taking the following suggestions in mind:
How To Ask Questions The Smart Way
I don't know what you want to 'validate'...what special characters? Do you want - or not want them?