I am trying to increase security on Email/Password input fields using regular expressions but I am having bad time because I cannot find what I am doing wrong. So basically I'm creating 2 variables where I'm storing my Regex pattern and after that I want to use jquery to catch the submit button and when .on('click') if there is added correct information by users to redirect them to next page for example. I have been testing my regular expression and they are matching my requirements - they are returning true for Email/Password after testing with .test(). Here is my code example of what I am trying to build:
var userValidation = /^[\w-]+@[\w-]+\.[A-Za-z_-]{2,4}$/;
var passValidation = /((?=.*d)(?=.*[a-z])(?=.*[A-Z]).{8,15})/gm;
console.log(userValidation.test('test@gmail.com')); // testing
console.log(passValidation.test('12345678Kksad')); // testing
Actual code which I am trying to run
$('.button').on('click', function(){
if ($('#user') === userValidation && $('#pass') === passValidation){
window.location.replace("http://ift.tt/gbk8l4");
}else{
console.log('not working properly');
}
})
Every time when I enter email and password in both input fields it returning the else statement does not matter if the information is correct or not according my regular expressions.
Any suggestions ?
Aucun commentaire:
Enregistrer un commentaire