JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" maxlength="20" size="25" value="" name="zipc" id="zipc">
<input type="submit" value="Search">
JavaScript
jQuery('#zipc').focusout(function () {
var _val = jQuery(this).val();
var _array = ["BF1 3AA", "Harry"];
for (var i = 0; i < _array.length; i++) {
if (_val.indexOf(_array[i]) != -1) {
alert('OH, snap! That\'s a BFPO postcode... We don\'t send stuff there. Bummer.');
jQuery('#zipc').val("");
}
else {
alert('Sorry');
jQuery('#zipc').val("");
}
}
});