Avatar of Jacque Scott
Jacque Scott
Flag for United States of America asked on

Adding a '-' for a zipcode

When a user is inputting a zipcode into a textbox I want the '-' automatically inputted when they type in their 6th number.  How do I do this?
JavaScript

Avatar of undefined
Last Comment
Jacque Scott

8/22/2022 - Mon
leakim971

check this cool plugin : http://digitalbush.com/projects/masked-input-plugin/

$("#zip").mask("999999-99");

Open in new window

ASKER CERTIFIED SOLUTION
Proculopsis

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jacque Scott

ASKER
These are both good options but I don't know how to call them.

leakim971: Where do I put your code?  I read the link you attached but I don't really understand jquery.


Proculopsis: I understand yours better because the link shows me how to call the function, but where do I add the function?  When I tried to add it between:


<script language="JavaScript" type="text/javascript" src="scripts/jquery.js"></script>
<script>

   'Added the code here

</script>

I got an error when saving.  It said 'Some Unicode character in this file could not be saved in the current codepage...'

I must be adding the code in the wrong spot.

Any suggestions?
SOLUTION
leakim971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Jacque Scott

ASKER
I gave leakim971 100 points because he showed me how to use jquery.  He didn't get all the points because I couldn't get the code to run in my program.

 Proculopsis got 400 points but I did need to change the numbers.  I needed 5 digits then '-' and then 4 digits.

Thanks guys for such good help.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy