javascript - Make user input start with either "BR" or "BT" -
i have input field , check if input entered starts either "br" or "bt". example br1234 valid jh1234 not valid. @ moment can check "br" , not "bt".
this code have far:
if (id.indexof('br') === 0) || (id.indexof('bt') === 0){ } else { id = "invalid id" document.getelementbyid('id').innerhtml = id return false;
check have proper parentheses in right positions. condition if
statement contains id.indexof('br') === 0
because closed parenthesis it.
if (id.indexof('br') === 0 || id.indexof('bt') === 0) { // ... }
you can use string.prototype.startswith
check if string starts desired string.
if (id.startswith('br') || id.startswith('bt')) { // ... }
Comments
Post a Comment