Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 7406 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have a interesting problem when I take the focus away from a phone number field. I have a script that automatically formats the data to the appropriate type

ex: when you enter 1223334444 it then converts to (122)333-4444

The script works fine(that part atleast). When I lose focus of that field and tab or click on another the data changes to this:

-1.2233e+09

Why is that happening and how can I tell my script to retain the calculation?

The field is defined as a number and auto enters the calculated value.

Thanks!

Chris

Posted

Define it as text, not number. Parentheses signifies a negative number and a hyphen in the middle doesn't make any sense. It's not a number, nor should you need a phone number to be a number field, since you won't be performing numerical calculations with it.

Why are you using a script when the auto-enter calculation works fine without one?

Posted

Well.....from a DB programmer standpoint, I don't really like to define text fields and use them as numbers. If there are numbers only being entered into a field, then I like to keep them define as a number. Probably shouldn't be so anal about it but you are right, there are no numerical calcs happening here so it will be ok to define in that format.

I guess the real question would be is it alright to break the "best practices" method of defining fields in a database that are used for opposite reasons? in this case, a text defined field and only storing numeric values? I just don't want to start developing bad habits, thats all.

I am not using a script for this. I am using exactly like you described with the auto-enter option and checking off the calc selection in the options of the field. We are on the same page there. smile.gif

Posted

Okay, you said you had a script to format the data, which was confusing.

The only reason to define fields as numbers is if they are numerical in nature or you will be treating them as such. Phone numbers, zip codes, etc. do not fall into this category. True, they do use digits, but are not numerical in nature (aren't used for mathematical calculations) and you definitely don't want them treated as numbers or you lose leading zeroes, have to account for hyphens and parentheses interpreting the number as a negative, and have to remove the first decimal point in the string. They are text strings and should be treated as such to avoid complication and confusion. If you do define them as numbers, you must take extra steps to ensure they are treated as text strings, which defeats the purpose of defining them as numbers.

If there are only going to be numbers entered into a textual field, then you can make it a number and validate that only numbers are entered. But in phone/zip cases, you can't assume other characters won't be entered and it's much easier to set up your fields to account for that than to clean them afterward.

This topic is 7406 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.