How to write a js regular season?

I have this regular season. It validates a string of numbers and the symbol "+".
phone.value = phone.value.replace(/[^+0-9]/g, "");

How to finish the regular season to limit the maximum dilnu string up to 11 characters?
March 19th 20 at 09:21
3 answers
March 19th 20 at 09:23
Solution
Leave the regular expression as it is, and just cut out the first how many you need characters:

phone.value = phone.value.replace(/[^+0-9]/g, ").slice(0, 11);

In General, you might want to look towards ready decisions (for example), instead of having to deal with such velosipedista.
Yes, norm, thanks - angie commented on March 19th 20 at 09:26
@angie, thank you for there is a button "mark a solution" - Jalen.Wilderm commented on March 19th 20 at 09:29
March 19th 20 at 09:25
March 19th 20 at 09:27
Try this regular season - /^[\+\d]{1,12}$/g

Regex101

Find more questions by tags Regular expressionsJavaScript