I've come up with a regular expression for Name validation that only allows characters like "_", "-", "'", and "."
Here is the regular expression pattern:
^[a-zA-Z][a-zA-Z0-9\.\-_']{1,24}$
The issue is that it's allowing names with "@" in them. You can see this in action in this Fiddle demo:
var str = "deepak@";
var str2 = "@@";
alert(str.match("^[a-zA-Z][a-zA-Z0-9\.\-_]{1,24}$"));//why is it allowing this?
alert(str2.match("^[a-zA-Z][a-zA-Z0-9\.\-_]{1,24}$"));//not allowing
Expected behavior: Names with "@" should not be allowed.
Note: When I tested this regex pattern on https://regex101.com/#javascript, it worked correctly