I am trying to format a US zip code as the user types, and need to add a dash between the 5th and and 6th characters if the user types more than 5 so the the zip code is formatted like
55555 or 55555-5555
what I have now adds a dash, but regardless if a 6th number is added
//zip code formatting
$(".zip-val").keyup(function() {
if($(this).val().length == 5) {
$(this).val($(this).val() + "-");
}
});