I have a single line text email field in my form, I want to block general emails that end in google.com, yahoo.com, etc. How would I do that?
Hello,
You can create a regular expression to validate emails.
I would start here: JavaScript RegExp Object
Then use this website to build it: https://regexr.com/
I would share mine but I don't have access to my Work PC.
Dear @cortese98,
The simplest option is a validator like this:
fd.spRendered(function () {
fd.field('Email').addValidator({
name: 'Email validator',
error: 'Domains google.com and yahoo.com are not valid',
validate:function(value){
if(value && (value.indexOf('google.com')>=0 || value.indexOf('yahoo.com')>=0)){
return false;
}
return true;
}
});
});
Or do you want something more complex? A regular expression will work better if all blocked emails follow some pattern.
Emails would contain any of these domains and should be blocked. I tried you code and it did not work as expected.
Dear @cortese98,
Here's the same exact code used for the Title field:
If it doesn't work - check console for errors.
Simple fix. This is a Plumsail form not a SharePoint Plumsail form. Changed to fd.rendered and it works. Thank you.
1 Like