jeudi 6 avril 2017

Make user input start with either "BR" or "BT"

I have an input field and I would like for it to check if the input entered starts with either "BR" or "BT". So for example BR1234 would be valid but JH1234 would not be valid. At the moment I can only get it to check "BR" and not "BT".

This is the code I have so far:

 if (ID.indexOf('BR') === 0) || (ID.indexOf('BT') === 0){
}
else {
ID = "Invalid ID"
document.getElementById('ID').innerHTML = ID
return false;

Aucun commentaire:

Enregistrer un commentaire