Custom Validation on submission

I have some basic script in a Custom Rule for a text control that makes a call to our DB checking if the value entered already exists and displays an error message. And as I type into this texbox the validation works perfectly.

On the form itself I have set Validate inputs on submit to True but when I submit the form, the above custom validation rule does not trigger. It is possible for another user to create the same data I'm checking for after successfully entering and validating but before submitting.

Do custom rules require some other way of validating on submission?

Hi @FirstFlight Can we see a screenshot of the validation setup? Is it making a new call to your db to check if the value already exists? Or is it comparing the value in the textInput to the values already called from your db?

One idea I have is to trigger a db query on Submit that will cause the form to check for valid inputs again. You'll need to have Reset after successful submit turned off (not checked).

Then, on success of the db query, trigger your actual form submit query & make the form submit query conditional based on whether the form is currently valid

Hi Tess, thanks for your suggestion - it's a simple yet great idea that we didn't consider. Either way we have actually decided to do things slightly differently and call on a service layer to do the work for us and do all the necessary checks for duplicates and immediately insert if there are none. I think this will be an even more reliable way for us but thanks for your help. This may well help us in other areas.

1 Like