[Solved] Email with single quote brake formalicious code

Hello, using formalicious I created an email field that is the field where the email is going to be send.
the problem is that it’s not working if the email contains a single quote: o’[email protected]

Error log:

An error occurred while trying to send the auto-responder email: You must provide at least one recipient email address.

What is the best way to proceed excluding telling the client that emails with single quotes are stupid! :sweat_smile:

Thanks!

This seems to be a general problem with FormIt (and not specific to Formalicious).

As far as I can tell, the value o'[email protected] gets converted to o'[email protected] which is then no longer a valid email address.

So in your call to FormIt you have to add the validator allowSpecialChars for your email field to make it work.

[[!FormIt?
    &validate=`email:allowSpecialChars:required`
]]

Or alternatively add a custom hook that reverts this specific conversion:

<?php
$email = $hook->getValue('email');
$email = str_replace("&#039;","'",$email);
$hook->setValue('email', $email);
return true;

As the client will inevitably run into further problems using an email address with a single quote in it could they be persuaded to set up an email alias of [email protected] so that people who have problems emailing them can use this alternative address. This way they get to keep their stupid address, but you don’t have to use it.

Doesn’t the email validator catch this? Better to just tell them their email address is invalid rather than trying to somehow alter it to be valid imo:

&validate=`email:email:required`

o'[email protected] is not an invalid email address! The validator allowSpecialChars doesn’t alter the value but rather prevents it from being altered to o&#039;[email protected].

&validate=`email:allowSpecialChars:email:required`
1 Like

Thank you all for your help.
I was thinking that emails should not have especial characters but unfortunately single quote it’s allowed but thanks to the

allowSpecialChars

It’s working.

So thank @halftrainedharry
What I’m doing now is using JS to make the validation, and ht e problem has been solved.

Thanks everybody!