Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<input id='test' type='text' />
<div id='msg'></div>
</body>
</html>
 
var postcodes = ["00-240", "80", "32", "90", "91"];
$('#test').keyup(function () {
    var val = this.value; 
    var m = $.map(postcodes, function (value, index) {
        var reg = new RegExp('^' + val + '.*$');
        return value.match(reg);
    });
    $('#msg').text(m.length && val.length ? 'VALID' : 'INVALID');
});
Output 300px

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers