javascript validate zip regular expression
- by phil
It's not working. Probably it's syntax error, but I can't figure it out.
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<script>
pattern=/^[0-9]{5}$/;
if (!pattern.test($('#zip').val))
{$('#zip').append($('<p>',{html: zip is invalid}));}
</script>
zip (US only): <input type="text" name='zip' id='zip' maxlength="5">