I would like to stop the user from writing certain punctuations inside the editText box. So for example, if they used '!' or ';' they will receive a toast to alert them not to use it when they click on the Done button, but if they use other punctuations such as commas or periods, it's fine.
Most of the codes here are how to swap or remove, but I don't really see a code for detecting so... How do I create the code to detect these certain punctuations in an editText box?
Thanks in advance!
if(yourText.matches("[^;]+[^!]")){
//Show the toast here
}
or
if(yourText.indexOf("!") != -1 || yourText.indexOf(";") != -1){
//Show the toast here
}
For a reference I created this JSFiddle, but this is javascript.