I want a client side validation of userid using javascript. Sample inputs are
!abcabc-def , abcabc , abc-defabcabc-def_hjk
I have made a regex ([\w]*[-]?[\w]+[\s]?[,]?[\s]?)+. It matches 2,3,4,5 as needed but also matches input 1, which is invalid.
Please let me know what is wrong in this regex.
^sign and end with$? Otherwise it will not match whole string.