java - How to write the if condition for this situation? -
i need set error password field condition "only 2~22 characters , symbols , _ - allowed."
but little stuck here.
here got far:
if( !(edittext.length() >= 2 && edittext.length() <= 22 ) || !(edittext.contains("-") || edittext.contains("_") || edittext.contains(",")) ) { //set error message }
but problem if input symbol other , _ or -, error message still doesn't show. input length, error message shows should though.
in java, use :
edittext.matches("^[a-za-z,_\\-]{2,22}$");
Comments
Post a Comment