mercredi 24 juin 2015

Javascript RegExp test

I am trying to verify a pattern of 5 characters - 5 characters - 5 characters with Javascript and I want it to fail if there are more or less than 5 characters between dashes. My test is as follows:

var patterns = new RegExp("[2-46-9A-DF-HJKMP-RTVW-YX]{5}-[2-46-9A-DF-HJKMP-RTVW-YX]{5}-[2-46-9A-DF-HJKMP-RTVW-YX]{5}","gi");

if(patterns.test(fkLicense) == true) {
    alert('good');
} else {
    alert('bad');
}

My issue is, no matter what I set the value of fkLicense to, the test passes. Any help will be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire