Formit: how to discard submission if email address does not contain org or com?

Summary

too much contact form

Step to reproduce

fill out form with any email address and any content

Observed behavior

form is submitted so long as the math test is passed (is it working??)

Expected behavior

first need to know how to check if email value contains a com or org

Environment

revo 2.7.x

1 Like

My first post with this new format, I am surprised the categories were removed, e.g. categories by topic, plugin, etc.
Anyway, I have not done any MODx work for several years and I need to know how after the email value is entered, to check whether it ends with .com or .org, and if not, fail silently, else submit as desired.
I know it would be something like:
<< after click submit button >> (or before, which would be better??)
If email contains com or org, then submit
otherwise do nothing, fail silently and do not show user anything different
</after click submit button>
Thank you, Tom

1 Like

Can I do:

[[+email:containsnot=com:or:containsnot=org:then=silently fail to submit]]

How do I do the ‘then’ part, not have the form submit – silently?? or better yet pretend to have been submitted, just not send the form email??

Thank you, Tom

1 Like

I’m a little confused about why you would want to do that? If you want to add additional validation to the email field, that’s one thing, but in such a case you’d want to at least show an error message so the user can correct the error.

Assuming you’re using FormIt to handle the form, to not send the email while still pretending it did, you’ll likely need to replace the default email hook with a custom one (snippet) that only sends it if your arbitrary condition is met.

I don’t think you’ll get it done just with output filters, because the email variable wont be available until the snippet has processed, so that’s too late to customise the hooks or something like that.

1 Like