Master Posted February 1, 2017 Report Share Posted February 1, 2017 How can I mask input to to add - after 5 digit zipcode in a submission page Quote Link to comment Share on other sites More sharing options...
MayMusic Posted February 1, 2017 Report Share Posted February 1, 2017 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.