I have a zip code field and I want to allow 5 digit OR 10 digit ie ##### or #####-####. If the user only puts in a 5 digit zip (ie 74074) it inserts a trailing - on the end (ie 74074-). I would like to NOT have the trailing - character, but still have it insert the - character if they type in a 6th character.
Thanks in advance for any suggestions!
Tom Moore
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a zip code field and I want to allow 5 digit OR 10 digit ie ##### or #####-####. If the user only puts in a 5 digit zip (ie 74074) it inserts a trailing - on the end (ie 74074-). I would like to NOT have the trailing - character, but still have it insert the - character if they type in a 6th character.
Thanks in advance for any suggestions!
Tom Moore
Ok, so I don't know if it is "THE" answer, but I found a way to do what I asked for. In my code, I inserted this after the mask:
var ZipMask = new InputMask("#####-####", "Zip");
ZipMask.blurFunction = function () {
if (this.value.substring(this.value.length -1, this.value.length) == '-') {
this.value = this.value.substring(0, this.value.length - 1);
}
};
Last edit: Tom Moore 2015-12-20