Hi,
How I can disable pasting into email confirmation?
I need to prevent that the user copy & paste the email with errors.
Best regards.
You have to do this with JavaScript. Try this snippet:
document.getElementById("field_conf_29yf4d2").addEventListener('paste', e => e.preventDefault());
document.getElementById("field_conf_29yf4d2").addEventListener('drop', e => e.preventDefault());
document.getElementById("field_conf_29yf4d2").addEventListener('autocomplete', e => e.preventDefault());
I tested this in my development environment. It works for paste and drag and drop. I didn't test autocomplete, but have no reason to believe it won't work.
Change "field_conf_29yf4d2" to the input id of your email confirmation field.
Don't forget to wrap the JavaScript in the script tags. This forum removes them from the display. Also, add the JavaScript to the after fields area of your form's Customize HTML page.
Thanks 😉 , It worked perfectly.
You inspired me to create a code snippet post: https://formidable-masterminds.com/disable-copying-email-address-into-email-confirmation-field/
@RobL from the slack group pasted this snippit a few weeks ago related to sending emails to all registered users or a particular access level in wordpress (admin, etc). You may could modify this for sending your e-mails if all of the users are registered on your wordpress and have the same access level:
add_shortcode('notificationtargets', 'getNotificationList');
function getNotificationList($atts) {
$eventType = $atts["eventtype"];
$notificationType = $atts["notificationtype"];
$addresses = array();// fill addresses array ...
$roleArray = array( 'author', 'subscriber' ); // whatever role(s) you want
$users = get_users( array( 'role__in' => $roleArray ) );
foreach ( $users as $user ) {
$addresses[] = $user->user_email;
}
if ($notificationType == "EMAIL") {
$addressCSV = implode(",", $addresses);
return $addressCSV;
}
}
Please login or Register to submit your answer
Could you clarify? I am not sure why someone would be pasting in a email notification?
Is not email notification is into the field "email confirmation", the user can copy the wrong email and paste into "email confirmation".