jeudi 1 novembre 2018

condition is met even when is false

I am trying to check if an input value is alphanumeric. According to regex101.com my regex should work. But all test results in "incorrect".

What am I doing wrong?

var alphaNumeric = /^[a-z0-9]+$/gi;
var input = page.input.getValue().toUpperCase();


if (input.length == 3) {
  alert(input);
  if (alphaNumeric.test(input)) {
    alert("correct");
  } else {
    alert("incorrect");
  }
} else {

}

Aucun commentaire:

Enregistrer un commentaire