Jump to content

Mask ZipCode to add - after 5 digit


Recommended Posts

Add the code below to the Footer of the page replace InsertRecordZip with ID of your zipcode field: InsertRecordFIELDNAME

 

<SCRIPT LANGUAGE="JavaScript">

function zip()
{

var zipcode = document.getElementById("InsertRecordZip").value; // here you get what the end-user typed
if (zipcode != "") {
document.getElementById("InsertRecordZip").value = (zipcode.replace(/[^\d]/g, '')); // then you strip off all the spaces

var zipcode1 = document.getElementById("InsertRecordZip").value;
document.getElementById("InsertRecordZip").value =  zipcode1.substring(0,5) + "-" + zipcode1.substring(5,10);
}
}

document.getElementById("InsertRecordZip").onchange=zip;
</SCRIPT>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...