Email address domain validation

Q: I need the email field to not accept any email address other than ones that contain @mail.co.za

A: I got the question above today, the solution is easy using Serverside Validation

Drag a Custom Serverside Validation action to the top of the "On Submit" event in your form, then drag an "Event Loop" action inside the "on Fail" event of the action, then add the code below in the action code box:

<?php
if ( strpos($form->data['email'], "@mail.co.za") === false ) {
  $form->validation_errors['email'] = "Your email address domain name is wrong.";
  return false;
}
?>

Please note that I have assumed that your email field name is "email".

 

Category: CFv4 Validation

Comments:

You need to login to be able to post a comment.