I am trying to match a string with a regex expression such that if that string contains anything apart from A-Za-z it should give a alert.
I did it using
if (myString.match(/^[0-9$&+,:;=?@#|'<>.^*()%!-]+$/)){
console.log("You are allowed to enter only alphabets");
}
EXAMPLE: for cyph3r or Hello@2022 it should log "You are allowed to enter only alphabets" and should accepts the strings like "Hello", "Stackoverflow" etc. Is there any better way to do so?