Include the hyphen into this regular expression, how?

You have to escape the minus sign using backslash.

var alphaExp = /^[a-zA-ZåäöÅÄÖ\s\-]+$/;

To stop them from using it in the beginning or the end, try something like this:

var alphaExp = /^[a-zA-ZåäöÅÄÖ\s]+[a-zA-ZåäöÅÄÖ\s\-]*[a-zA-ZåäöÅÄÖ\s]+$/;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)