08-04-2021 05:19 AM - edited 11-08-2021 06:53 AM
In 2018 the user dongill asked "Is it possible to do a email validation for “Known Guest” account creation in the sponsor portal?
We have a need to prevent sponsors creating guest accounts with their corporate email addresses?"
Jason Kunst crated a script to solve this:
The part Script will allow only the domains ("domain1","domain2","domain3") is functional.
But the part Script will allow all the other domains except the domains("domain1","domain2","domain3") isn't.
The user grabonlee has already pointed this out in the comments and Jason has asked him to open a new one thread.
Because I didn't find such a thread or anything else to solve this problem I asked this again.
How can I ristrict domains for the guest email adress?
Our ISE is version 3.0 Patch 4.
Solved! Go to Solution.
12-13-2021 07:38 PM
Try changing the line with the regex of Restrict the email address entered when creating a known account as below:
from
return /^(\w+\.?)+@(domain1|domain2|domain3)\.com$/.test( value );
to
return /^(\w+\.?)+@((?!(domain[1-3])).)*\.com$/.test( value );
11-08-2021 06:51 AM
Now one who can help me?
Jason???
12-04-2021 03:03 PM
Did you Enable Portal Customization with HTML and JavaScript ?
Did you make any other changes to the script?
Do you get errors on the web console? What are the errors?
You need to do some JavaScript troubleshooting.
12-09-2021 11:56 PM
Hi Thomas,
First at all... Why has anyone marked your post as "Accept as Solution"?
I reversed it.
Your questions:
- Did you Enable Portal Customization with HTML and JavaScript ?
Of course. Otherwise I couldn't said "The part Script will allow only the domains ("domain1","domain2","domain3") is functional." in my initial description...
- Did you make any other changes to the script?
The only thing I've changed was the entry for "var domains (line 5) and the alert output (line 13).
- Do you get errors on the web console? What are the errors?
I don't get any errors.
How can I troubleshoot JavaScript. Is there any possibility to some kind of step-by-step-debug?
12-13-2021 10:40 AM
I marked my answer as the Solution because I was the first person to respond in over 1 month and "You need to do some JavaScript troubleshooting" is The Solution even though you didn't like it.
There are 1000's - maybe 1000000's - of JavaScript resources on the Internet. However, the ISE/NAC community probably isn't the best place to find it.
If you want people's help - especially with custom scripting / programming - you need to include the HTML+JS code you are using so people can easily try to use it, reproduce your problem, and potentially suggest a fix for the problem you are seeing.
See How to Ask The Community for Help .
12-14-2021 12:29 AM
@thomas wrote:...
"You need to do some JavaScript troubleshooting" is The Solution even though you didn't like it.
...
That's a joke...
A solution is only a solution which will fix the problen not investigate it!
It's the same if I open a case and the TAC engineer closes it with the words: "You have to do troubleshooting."
@thomas wrote:...
There are 1000's - maybe 1000000's - of JavaScript resources on the Internet. However, the ISE/NAC community probably isn't the best place to find it.
...
Of course this community is the best place because it't an ISE related thing!
12-13-2021 07:38 PM
Try changing the line with the regex of Restrict the email address entered when creating a known account as below:
from
return /^(\w+\.?)+@(domain1|domain2|domain3)\.com$/.test( value );
to
return /^(\w+\.?)+@((?!(domain[1-3])).)*\.com$/.test( value );
12-14-2021 03:51 AM
That's from the script which will allow only the domains ("domain1","domain2","domain3").
But this is functional!!!
I'm talking about the second script which will allow all the other domains except the domains("domain1","domain2","domain3")!!!
<script> $(document).on("pageshow", function(){ setTimeout(function() { $('.personBeingVisited').val(""); var domains = ["domain1","domain2","domain3"]; function validateDomain(me){ var idx1 = me.target.value.indexOf("@"); if(idx1>-1){ var splitStr = me.target.value.split("@"); var sub = splitStr[1].split("."); if(domains.indexOf(sub[0])>-1){ me.target.value=""; alert("Enter a valid email address."); return false; } } } $(function () { $('.personBeingVisited').blur(function (ele) { validateDomain(ele); }); }); }, 5000); }); </script>
12-14-2021 05:22 PM
Did you not test it? It's exactly because the other script already working for you and because it's easier to tweak the regex to do the opposite.
12-15-2021 02:03 AM
Ahhh...
Now I understand.
Instead of tweaking the original exclusion script you tweaked the "Allow only" script.
I've already had the idea to make it negativ with the exclamation mark but I guess I did it the wrong way (I'm not a programmer...).
And because I want to exclude our company domain from the guest email address field and to allow only our company domain in the person being visited email address field I had to change the field name in the exclusion script from .personBeingVisited to .email
Also I had to make the rule name (customemailvalidator) in both scripts unique because I implemented both in one form.
In the exclusion script I changed it to visitoremailvalidator and in the allow only script to visitoremailvalidator.
Here is the complete script (domain1|domain2|domain3 and .com should be changed to the needed values):
<script> $(document).on("pageshow", function(){ setTimeout(function() { $('.form-horizontal').validate(); $(".email").rules("add",{visitoremailvalidator:true}); $.validator.addMethod("visitoremailvalidator", function(value, element) { if(value == ''){ return true; } return /^(\w+\.?)+@((?!(domain1|domain2|domain3)).)*\.com$/.test( value ); }, 'Enter a valid email address.'); $(".email").on("input", function (){ $(".email").validate(); }); }, 5000); }); </script>
<script> $(document).on("pageshow", function(){ setTimeout(function() { $('.form-horizontal').validate(); $(".personBeingVisited").rules("add",{visitedemailvalidator:true}); $.validator.addMethod("visitedemailvalidator", function(value, element) { if(value == ''){ return true; } return /^(\w+\.?)+@(domain1|domain2|domain3)\.com$/.test( value ); }, 'Enter a valid email address.'); $(".personBeingVisited").on("input", function (){ $(".personBeingVisited").validate(); }); }, 5000); }); </script>
08-24-2023 06:44 AM
how to place this script in portal page ?
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide