Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Custom validation for search field - stuck in loop.

Featured Replies

Greetings,

 

I have a global field that is acting as a search bar to perform a find with the data stored in it. I have set an OnObjectKeystroke script trigger to the field to activate a script if the user presses the enter key while inside the field. Since most users are used to hitting enter on their keyboards to perform a search and it's much quicker, I've adopted this method as opposed to a search button. 

 

I would like to prompt the user with a warning dialog if they press enter while inside the search field, but happen to leave the field empty. The custom dialog would tell them to type some search criteria in, instead of leaving the field empty to avoid performing a blank search.

 

So far most of the script I came up with works, but for some reason it gets stuck in a loop during the last simple steps and I can't get out of it.

 

I'm trying to have the following occur:

 

- Exit the search field, and make it lose the focus.

- Show a custom dialog telling the user of the error and prompting them to press "OK".

- Upon pressing OK, enter the search field again and bring it into focus to set the cursor in the field so that the user can retype a correct value.

 

The default FileMaker field validation that is found in the field's Options settings performs something very similar to what I described above. I'm trying to achieve a similar effect, but using a script instead to have more custom control and flexibility with the warning dialogs.

 

Any help much appreciated.

Custom validation - Search field.fmp12.zip

I think a better user experience would be for nothing to happen. Hitting Enter in an empty search field should just skip the search altogether and go to the next field in the tab order.

  • Author

Thanks Brooks, that worked like a charm! I also noticed that just placing a simple Halt Script step right after the second and final Go to Field step also managed to fix the issue, fully stopping the main script and preventing it from recurring indefinitely (interestingly, an "Exit Script" step on the other hand will not stop the loop).

 

I guess it has something to do with entering a field, exiting that field, and then entering that same field again shortly after, which in return causes the script to get hung up.

 

Thank you David, that sounds like a good option as well (since pop-up dialogs can sometimes be a little obtrusive to some users).

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.