adding dash after 5 character in zip code

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
I have a address field and which  is having postal code as a sub field , so my question is like after i am entering 5 numbers a dash symbol must come. Do  i have any native QuickBase option
Photo of John Thomas

John Thomas

  • 1,062 Points 1k badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,326 Points 50k badge 2x thumb
I presume you are talking about Zip + 4 where there is an optional suffix.

one suggestion is to have the Zip field be called [Zip 5] be a text field and set the field properties to limit to 5 characters.  Then have a field called [Zip 4] and limit to 4 characters.  Show these in add and edit mode.

Then have a formula field

List("-", [Zip 5], [Zip 4])

This presumes that your data entry is by hand and not imported.
Photo of John Thomas

John Thomas

  • 1,062 Points 1k badge 2x thumb
Photo of John Thomas

John Thomas

  • 1,062 Points 1k badge 2x thumb
I was asking like this . Do i have any native Quick Base option
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 47,130 Points 20k badge 2x thumb
I don't think so.
Photo of John Thomas

John Thomas

  • 1,062 Points 1k badge 2x thumb
If there is any native quick base option Please let me know that one


Other wise using javscript we can do this one

$("#_fid_45").keyup(function() {
    let val = $(this).val();
    if(val.length > 5) {
        let digits = val.split(/(\d{1,5})/);
        let str = "";
        for (let group of digits)
        {
          if (/^\d+$/.test(group))
          {
            str += group + "-";
          }
        }
        str = str.substring(0, str.length - 1);
        $(this).val(str);
    }
});

 Insted of _fid_45 give your fid Id
Photo of Angel

Angel

  • 724 Points 500 badge 2x thumb
How and where are you referencing this JS? 
So I am assuming you create a Formula Text field with HTML enabled and writing this piece of code? But where are you calling it from?
Photo of John Thomas

John Thomas

  • 1,062 Points 1k badge 2x thumb
Using IOL Technique.
Create a formula text field and have the below code

Create a page in Pages name it module.js and have the above code
with field id replaced. Then it will work ,You can name the page
whatever but you need to make the same name on the formula Field


"<img qbu=\"module\" src=\"/i/clear2x2.gif\" " & "onload=\"javascript:if(typeof QBU=='undefined'){QBU={};$.getScript('" & URLRoot() & "db/" & Dbid() & "?a=dbpage&pagename=module.js&rand='+Math.random())}\">"
(Edited)