Cognito-forms – Formats and Calculations

cognito-forms

  1. Can I have a custom format in a field?

For example one of my fields is a MAC Address and should look like 12:3A:5B:78:90:1E however I only want the user to have to type 123A5B78901E.

  1. I also have a drop down menu with various items in the list. When I select an item a want a number to show up in another field and be able to use that number in a calculation.

Can this be done?

Best Answer

I am a developer for Cognito Forms

  1. We do not have a way to auto format a field or change entered text from "123A5B78901E" to "12:3A:5B:78:90:1E". However you can use a calculation and pull the information entered into a text field over into a calculation field that will format the text for you. This will not validate the text though. In order to do this start with a Text field and then create a Calculation field just under it. You can then place this calculation into the Calculation field. In this example I am targeting the Text field titled "Text Field". This calculation will place a colon after every 2 items in the string. It wont change the Text field but the new calculation field will show the formated entry.

=TextField.Substring(0,2) +":"+ TextField.Substring(2,2) +":"+ TextField.Substring(4,2) +":"+ TextField.Substring(6,2) +":"+ TextField.Substring(8,2) +":"+ TextField.Substring(10,2)

  1. If you want the number to be generated in a field that users cant edit I would recommend using a Calculation Field. This will show users the number and allow you to use the number in other calculations. You will need to set the "Type" of this Calculation field to "Numbers". You can then use this calculation to reference your choice field and assign numbers based on the selected drop down option. In this example I have used "Choice" as the Choice field title and then First, Second, and Third as each choice option. I have then assigned a number to each option First = 10, Second = 20, and Third = 30. If nothing is selected then 0 will be placed in the Calculation field.

=Choice = "First Choice" ? 10 : Choice = "Second Choice" ? 20 : Choice = "Third Choice" ? 30 : 0