Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Limit Field Input


fx_uk
 Share

Recommended Posts

I have been looking for a way to limit a fields input characters

 

As with almost every other system available, I want to set for instance

 

Field 1 to have a maximum of 10 characters, I dont want to use field validation as this shows an annoying popup when you exit the field and can be quite obtrusive.

 

Is there a way to prevent the user typing any extra info into a field.

 

I have also thought about an auto enter calculation, stripping the last part of the field away, but imagine a user types to their hearts content only to find

it gets deleted right infront of their face. Surely it would be easier to just force a STOP !

 

Any help greatly appreciated !

Link to comment
Share on other sites

How about this?

 

Set Field [AnyTable::GlobalTextField A, ""]

Loop

Exit Loop If [Not isempty(AnyTable::GlobalTextField A) and Length(AnyTable::GlobalTextField)

..Show Custom Dialog ["Field 1", "Enter a value for Field 1. "&Case(length(GlobalTextField A)>5, "¶"&"Five characters or less, you blithering idiot, how many time do I have to tell you?"), Allow Input, AnyTable::GlobalTextField A, "OK", "Cancel"]

If [Get(LastMessageChoice)=2]

Exit Script []

End If

End Loop

Set Field [Table::Field 1, AnyTable::GlobalField A]

Link to comment
Share on other sites

Thanks for the almost immediate reply...

 

That does work yes (well with the following mods)

however still involves a popup which im trying to prevent.

 

But for any others wishing to use this try it as follows :

 

 

Loop

Exit Loop If [Not isempty(AnyTable::GlobalTextField A) and

 

Length(AnyTable::GlobalTextField A )

 

Set Field [AnyTable::GlobalTextField A, ""]

 

..Show Custom Dialog ["Field 1", "Enter a value for Field 1. "&Case(length(GlobalTextField A)>5, "¶"&"Five characters or less, you blithering idiot, how many time do I have to tell you?"), Allow Input, AnyTable::GlobalTextField A, "OK", "Cancel"]

 

If [Get(LastMessageChoice)=2]

Exit Script []

End If

End Loop

Set Field [Table::Required Field, AnyTable::GlobalField A]

Link to comment
Share on other sites

To get back to your original question, FileMaker doesn't assess what has been entered into a field until the field entry is completed — attempting to commit the record by tabbing out of the field, clicking out of the field, hitting Enter, or entering a different mode. Therefore there's no native way of cutting you off at 5 keystrokes during data entry itself. You could modify the above dialog and dispense with the loop and instead just set the Field 1 value to Left(AnyTable::GlobalTextField A, 5), but that doesn't keep the user from typing 39 characters, it just ignores all but the first five.

Link to comment
Share on other sites

I pretty much had an idea that is what I would have to do.

 

I suppose after they fill out the field a few times they will get used to it !

 

A bit of a shame though, if it was to evaluate as your typing then this would open a world of opportunity, such as when user types 6 characters auto tab them to the next field / portal row or even use a free script fire plugin

 

ahh well, best wait for filemaker V20 (when they hopefully fix the printer selections too lol )

 

Cheers for your input, appreciated !

 

 

 

To get back to your original question, FileMaker doesn't assess what has been entered into a field until the field entry is completed — attempting to commit the record by tabbing out of the field, clicking out of the field, hitting Enter, or entering a different mode. Therefore there's no native way of cutting you off at 5 keystrokes during data entry itself. You could modify the above dialog and dispense with the loop and instead just set the Field 1 value to Left(AnyTable::GlobalTextField A, 5), but that doesn't keep the user from typing 39 characters, it just ignores all but the first five.
Link to comment
Share on other sites

Here is my solution. It is copyrighted so you have to give me credit whenever you use it and submit royalties of 5c by Paypal whenever it is triggered. Oh how I wish you could do that! ;)

 

Anyway, here is is for nothing, nada, zip, free...

 

A field you want to limit in this way has an input field and a data field. So we have:

 

Text10input

Text10data

 

Text10input has field options set for a calculated replace (always replace existing value):

 

Left(Text10input; 10) & TextColor ( Middle ( Text10input ; 11 ; 999 ) ; RGB ( 250 ; 0 ; 0 ) )

 

What this will do (when the user leaves the field) is change all characters after the first ten into red indicating that they are beyond the field limit. However, this does not delete the additional characters.

 

Text10data has field options set for a calculated replace (always replace existing value):

 

Left(Text10input; 10)

 

Thus, Text10data will contain only the first 10 characters from the input field. This is the field that will be used/displayed everywhere else in the system. It is the "real" data for the field.

 

Issues with this technique:

1. requires two fields for each field - input and data

2. red text only updates when the data is committed to the field (e.g. when the user exits the field)

 

Advantages of this technique:

1. user gets visual feedback that their data entry has a problem

2. additional characters are not deleted and the user can see how many extra they have typed

Link to comment
Share on other sites

That's pretty damn cool :)

 

 

[whiny puppy mode]

 

I wish to mention that my original script with the Custom Dialog leaves the attempted entry string intact for the end user to modify to a 5-character-limited rendition

 

[/whiny puppy mode]

Link to comment
Share on other sites

Hi David

 

Thats a pretty neat way to do it, Luckily I dont need to limit too many fields

just 1 infact, a portal row which prints multiple portal rows out on a report

 

Without limiting people dont understand why their text they typed cannot be seen, but with your method at least they will have an idea !

 

Both above are good, I dont think the popup will suite for mutliple portal rows

but could be good for single data types...

 

Im going to implement this and give it a test run. THANKS

 

P.S

 

I do have faith, really... I love filemaker and have watched it grow over the years to be a great tool, it just seems the printer issue should have been sorted sooner.

 

I know this is off topic but they should have 3 print scripts

 

Print Setup (doesnt restore printer)

Printer Selection (with restore / no dialogue)

and Print (with restore / no dialogue)

 

I guess ill send that into them !

Link to comment
Share on other sites

 

A field you want to limit in this way has an input field and a data field. So we have:

 

Text10input

Text10data

 

Text10input has field options set for a calculated replace (always replace existing value):

 

Left(Text10input; 10) & TextColor ( Middle ( Text10input ; 11 ; 999 ) ; RGB ( 250 ; 0 ; 0 ) )

 

How do you fancy improving the above !! :-)

 

I have a portal row which displays on a report, I have given the user an option of two styles however the field length is different on both (landscape / portrait)

 

If I use the above technique it does work ok to an extent, however...

can you think of a way to handle both upper and lowercase.

 

for example...

 

"I WANT THIS ITEM TO SHOW ON THE REPORT" is longer than

"I want this item to show on the report" but the same character length...

 

Any ideas ! or complex calculations ?

Link to comment
Share on other sites

:) So now you realise what you were really after in the first place - you didn't really want to limit the number of characters at all - you wanted to limit the amount of space the text took up. As you realise, the amount of space text takes depends on three main things - font, size and character (plus other things like syle - bold, etc).

 

To get a solution, you need to control the variable factors above and then be able to calculate the pixel size of the typed text.

 

Just for interest sake I will work on a calculation. Check back soon.

Link to comment
Share on other sites

Hi David...

 

Its actually both I wanted and I really appreciate your help.

 

First method I need for limitting an id number which is entered by the customer, so the example above suites perfectly.

 

Second is something I thought about after using the example until I realised it would require a little more work...

 

Thanks.....

 

Steve

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

Terms of Use