W
W
wufapexef2017-09-27 21:51:08
JavaScript
wufapexef, 2017-09-27 21:51:08

How to make a regex to check for: two digits, capital letter?

I want to validate the entered password.
If checking for the presence of a single digit is simple:

addNumber: function (value) {
          return /\d/.test(value)
        }

Then check two digits already begin black magic.
Plz tell me 2 regex:
1. to check for the presence of two / three digits
2. to check for the presence of a Capital Letter.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Petya Persianov, 2017-09-27
@wufapexef

capital letter:

reg = /[A-Z]/;
return reg.test(str);

for the presence of two / three digits:
reg = /[0-9]{3}/ (для трех)
return reg.test(str);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question