If/else syntax on password verification in javascript -
i'm new javascript , trying list out characters missing failed password tell users need input.
window.onload = function() { var info = document.getelementbyid("info"); var test = document.getelementbyid("myform").test; test.onclick = function(e) { e.preventdefault(); var pw = document.getelementbyid("myform").pw.value; var formula = /(?=.*[a-z])(?=.*[a-z])(?=.*[0-9]).{6,}/; if(formula.test(pw)) { document.getelementbyid("myform").submit(); } else if pw.match(/\d/g) == null { info.innerhtml = "you need number"; console.log(pw.match(/\d/g)) } else { info.innerhtml = "you need number." } }; };
the above first run through of checking if user inputted password numbers. keep getting
uncaught syntaxerror: unexpected identifier
in chrome dev tools pw.match portion underlined. i've looked elsewhere online , syntax looks correct. going wrong?
you need parentheses around condition of if
block.
else if (pw.match(/\d/g) == null) { ...
Comments
Post a Comment