I have a regular expression check to determine if the input is valid or not. It returns false for all expected wrong inputs. However, after passing the input check successfully once, there is an odd situation where an input (I only found one so far) that should fail will now pass until I refresh the page and start over.
let tstr = '^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])';
let treg = new RegExp(tstr);
console.log(treg.test(*input value*));
The input that I noticed acting strange is
Testword
If I put the string above as an input before any checks pass, then it will fail. If at any point of testing a valid input passes the check, ex 'Wordword1', then I can reenter 'Testword' and it will pass even though it should fail. I can't understand the reason for this inconsistency. Why is this happening and how can I prevent this?
Via Active questions tagged javascript - Stack Overflow https://ift.tt/14HfyEx
Comments
Post a Comment