I am looking for a Javascript regular expression which has 2-4 letters, followed by a dash, and then 5-6 numbers.
Valid examples would be: AB-123456, ABC-12345, ABCD-123456
I tried checking data entered in a field and then try the regex like this:
$('#inputid').change(function() {
var myregex = '/^([a-zA-Z]){2,4}-([0-9]){5,6}$/';
if(myregex.test($(this).val()) == false)
{
alert("Bad data");
}
});