You are viewing limited content. For full access, please sign in.

Question

Question

CSS to always display three digits?

asked on December 5, 2016 Show version history

What could I do to get my Form field input to always display in three digits?  Normally, the input will be filled in with two digits, but I need the results to always display three digits:  44 must show as 044

This didn't work:  #q34 input {display:000;}

0 0

Answer

SELECTED ANSWER
replied on December 5, 2016

Try This

=CONCATENATE(INDEX(Legal_Address.Quarter,ROW()),"-",INDEX(Legal_Address.Section,ROW()),"-",INDEX(Legal_Address.Township,ROW()),"-",RIGHT(CONCATENATE("000",INDEX(Legal_Address.Range,ROW())),3),"-",INDEX(Legal_Address.Meridian,ROW()))

 

1 0

Replies

replied on December 5, 2016 Show version history

Hi Connie

Another Approach is to put it on the users to enter a 3 digit at time of input.
Have the field be a String Field with a Reg Expression Constraint requiring 3 digits. 
This is found on the Fields Advanced tab, Reg Expression Validation  Put \d\d\d in the field

This will force a 3 digit entry, ie: 044 instead of 44

You could have a tool tip or Tex Above\Below that explains the requirement to the user.

1 0
replied on December 5, 2016

Thanks, Steve.  I did think of that, but was trying to keep the field layout the same.  This collection field for the location of the burn is already as tight as I can get it.  I think I would only be able to use your idea if I went back to having the individual fields under each other, instead of the four fields beside each other across in one line.

0 0
replied on December 5, 2016 Show version history

You can't do this with CSS. You need to use JavaScript.

Here is a very crude method. I haven't tested it but it should work:

$(document).on("ready", function() {
  $("#q1 input").on("change", function() {
    var currentVal = $(this).val();
    if (currentVal.length == 1) {
      $(this).val("00" + currentVal);
    } else if (currentVal.length == 2) {
      $(this).val("0" + currentVal);
    }    
  });
});

Replace "q1" with the id of your field.

Note that this will only work with single line fields. It won't work with Number fields.

0 0
replied on December 5, 2016

Thanks, Ege!  Have never used JavaScript before, but I cut and pasted from above, popped it into my Form and changed the #q1 to #q34, but it did not change the action when I tested.  Is there something I'm missing?

Here's what my test did:

I need the Township field to end up as 044, so that the result of the collection field ends up looking like this:  NW-10-044-12-W4.

0 0
replied on December 5, 2016

Hi Connie, I think we can just edit the Concatenate Formula that we used to create the string to add the 0, Not sure if I still have it, Can you paste it here and I can have a look.

0 0
replied on December 5, 2016

=CONCATENATE(INDEX(Legal_Address.Quarter,ROW()),"-",INDEX(Legal_Address.Section,ROW()),"-",INDEX(Legal_Address.Township,ROW()),"-",INDEX(Legal_Address.Range,ROW()),"-",INDEX(Legal_Address.Meridian,ROW()))

0 0
replied on December 5, 2016

By the way, Steve, this Concatenate Formula has been working beautifully for me.  It allows me to present the legal address in a nice clean format for the Fire Chief to view before approving, and really simplifies filling in the Legal Address fields, as well!  Thanks, again!

0 0
SELECTED ANSWER
replied on December 5, 2016

Try This

=CONCATENATE(INDEX(Legal_Address.Quarter,ROW()),"-",INDEX(Legal_Address.Section,ROW()),"-",INDEX(Legal_Address.Township,ROW()),"-",RIGHT(CONCATENATE("000",INDEX(Legal_Address.Range,ROW())),3),"-",INDEX(Legal_Address.Meridian,ROW()))

 

1 0
replied on December 5, 2016

That worked!  I had to switch the extra info to be the middle bunch of numbers, but in essence it worked!  Thanks so much!

0 0
replied on December 5, 2016

Oops! Good pick up. Glad this has worked for you.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.