rinaldy31
rinaldy31

Reputation: 127

must at least have number and characters regex

I still don't understand how to use regex and there is regex like this :

/^[a-zA-Z0-9\s]+$/

and i use it in javascript

$('#oldPass, #newPass, #confpass').keydown(function (e) {
         var inputValue = e.key;
          if(inputValue.match(/^[a-zA-Z0-9\s]+$/)){
              return;
          }else{
              e.preventDefault();
          }
      });

it works, i can't type anything beside alphanumeric, but how can i make that the new password must contain combination number and characters?

Upvotes: 0

Views: 25

Answers (1)

Prakash N
Prakash N

Reputation: 1070

Minimum of 8 letters with atleast one letter and number.

^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}

check this link for verification https://regex101.com/r/DcxNSc/1

Upvotes: 2

Related Questions