I just checked and it works absolutely fine for the postcodes you mentioned. Perhaps there are issues in other browsers - that I have not checked anything save or the latest Firefox.
Either way, please make sure the parseInt
returns what you expect. You could do something like this:
var parsed = parseInt(postcode, 10);
if (parsed > 99 && parsed < 10000 && postcode != '') {
// code goes here...
} else {
console.log(postcode, parsed);
}
The above will print the bad values to the console and you will probably find out what's wrong. Maybe they return NaN
? Maybe the input wasn't trimmed?
By the way, I would rework your condition. postcode != ''
is a narrow case; what if you input 'abc'
? All such values will be NaN
after passing them through parseInt
, so you could as well do something like this:
var parsed = parseInt(postcode, 10);
if (!!parsed && parsed > 99 && parsed < 10000) {
// code goes here...
}