ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

Server side validation to Block Free Emails (Gmail, Yahoo)

M.Abletech 31 Jan, 2019
Hi,

I wish I can Block Free Emails (Gmail, Yahoo) and allow Business emails in forms. I've seen how to do so with server side validation, but I wish I can do it wit client-side validation.

Any advice?

Thanks
healyhatman 31 Jan, 2019
You want to block the largest email providers in the world? Well sure off you go, you can make a custom JS validation there's a FAQ about it.
https://www.chronoengine.com/faqs/74-chronoforms/chronoforms6/5293-validating-fields
M.Abletech 01 Feb, 2019
Hi Healyhatman,

as a matter of fact I need people's corporate email adress and I want to prevent them to put generic email adress.

I've already found a very good post by Greyhead :
https://www.chronoengine.com/forums/posts/t84695/block-e-mail-domains

But in this post it seems to me that it is a server side validation in php. I need instead a a client side validation.
So I though I need to put the name of a javascript piece of code in the Custom Function Box of the element I need to validate. Can I put a php code instead ?

Thanks!
healyhatman 01 Feb, 2019
No you can't, because PHP is serverside code. You'll have to code it yourself. Also be aware that a lot of small businesses still use GMail addresses, especially if they don't have their own website and sometimes even if they do.
healyhatman 01 Feb, 2019
http://www.sagarnangare.net/javascript-validation-code-to-block-free-emails-gmail-yahoo-allow-business-emails-in-forms/

With modifications
jQuery.fn.form.settings.rules.nofreemails = function(value) {
var reg = /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)(?!yahoo.co.in)(?!aol.com)(?!abc.com)(?!xyz.com)(?!pqr.com)(?!rediffmail.com)(?!live.com)(?!outlook.com)(?!me.com)(?!msn.com)(?!ymail.com)([\w-]+\.)+[\w-]{2,4})?$/;
return !(reg.test(value));
};
Then in your validation rules for the field you would put
nofreemails:You must not use a free email, only corporate emails are allowed!
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com