Jump to content

Custom validation for search field - stuck in loop.


Alex117

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

Recommended Posts

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

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

This topic is 4026 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.