Check if zip is 5 digit number, if not then display ‘zip is invalid’. I want to use onBlur event to trigger the display. But it’s not working.
<script>
$(function(){
function valid_zip()
{
var pat=/^[0-9]{5}$/;
if ( !pat.test( $('#zip').val() ) )
{$('#zip').after('<p>zip is invalid</p>');}
}
})
</script>
zip (US only) <input type="text" name='zip' id='zip' maxlength="5" onblur="valid_zip()">
you are now using jQuery, don’t do inline coding…
should just be