Solved

Input box Filmaker Pro 11

Posted on 2011-09-05
2
412 Views
Last Modified: 2012-05-12
I have a database (see attached) it hase a one table and a main layout. The layout out has a button that lets the user enter any number. The inputted number populates the field 'Enter_Number' which is set to receive only numeric data. Is there a way that when the users inputs their answers, the script can check to see that the value entered is indeed only numbers.
InputBox.fp7
0
Comment
Question by:PachecoPrimo
2 Comments
 
LVL 12

Expert Comment

by:North2Alaska
ID: 36485736
I use a custom function, IsNumeric( value, separator ) that returns true or false.  I don't recall where I found it and I don't claim to have written it.  I just use it...


Let
(
   [
   decSep = If (separator = ""; "."; separator);

   trimmedValue = Trim (value);
   filteredValue = Filter ( trimmedValue ; "0123456789-" & decSep );
   lengthOk =    If (Length (trimmedValue) = Length (filteredValue);  True;  False);

   dotOccurence = PatternCount (filteredValue; decSep);
   dotOk = If (dotOccurence = 0 or dotOccurence = 1; True; False);

   minusIndex = Position (filteredValue; "-"; 1; 1);
   minusOk = If (minusIndex = 0 or minusIndex = 1; True; False)
   ];
   If (lengthOk and dotOk and minusOk;
      True;
   /*else*/
      False
   )
)

Open in new window

0
 
LVL 1

Accepted Solution

by:
soholm earned 500 total points
ID: 36522197
A way to check if the entered value is indeed numbers could be this:

Exact (Main::Enter_Number ; GetAsNumber( Main::Enter_Number) )

Open in new window


Unfortunately, the isValid() function will not cover here. It will return 'true' for a number field as long as the input contains some number even if the input also contains letters and other characters.

You may have perfectly good reasons for scripting this, but consider just using an input field on the layout instead. If you define the input field to "Always" validate instead of "Only during data entry" you may rely on FileMaker taking care of the testing instead, regardless the input situation. You may also want to clean up the input by using the nice filtering custom function proposed by North2Alaska.

The build-in FileMaker alert does not aestetically work well on top of a scripted custom dialogue box, which is another reason for avoiding a dialogue box if possible.

This could be done by putting an auto-enter calculation on the input-field. When entering you run above 'exact'-test, and if it fails you simply reset the field.

Finally, you can add script triggers on the input field if you need any further functionality to run at the time of input.

Hope this may help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FM - Sorting Titles 5 73
FileMaker PDF Page Size 4 128
Unable to Find records in FileMaker Pro 3 55
Filemaker Pro - Export to Excel as Pivot Table 5 31
Conversion Steps for merging and consolidating separate Filemaker files The following is a step-by-step guide for the process of consolidating two or more FileMaker files (version 7 and later) into a single file with multiple tables. Sometimes th…
Problem: You have a hosted FileMaker database and users are tired of having to use Open Remote or Open Recent to access the database. They say, "can't you just give us something to double-click on rather than have to go through those dialogs?" An…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question