Skip to content Skip to sidebar Skip to footer

Validation Using \p{l} In Javascript Regexp

**var pattern = /^[\p{L}0-9 @#'!&(),\[\].+/-]{1,100}$/;** \\first of all I din understand this pattern. someone plz explain it to me\\ if (!pattern.test(Name)) {

Solution 1:

Change

/^[\p{L}0-9 @#'!&(),\[\].+/-]{1,100}$/

to

/^[\p{L}0-9 @#'!&(),\[\].+\/-]{1,100}$/

                          ^^

since you have to escape slashes / since you have defined them to be delimiters.

The meaning of the regex is that your entire string has to be between 1 and 100 characters of the listed characters, numbers and letters.

Post a Comment for "Validation Using \p{l} In Javascript Regexp"