HelpSpot Help Desk Software | HelpSpot Blog | HelpSpot Support

Portal email validation


Perhaps this is built-in already and I am missing it, but is there a way to validate email addresses in the portal against valid domains? For instance, we are a .org domain, but my users have a bad habit of entering their email with .com instead. I’d like the portal submission to fail if the email domain doesn’t match the list.

Perhaps I just need to edit the php file?



Currently there’s no built in way to do that. You would indeed need to edit the request.tpl.php template and just put a simple javascript check in there on the form submit to prevent that and throw up an alert.


For anyone interested, I added the following script to accomplish this. Basically the submit button only enables when a whitelisted domain is entered. (Formatting is not cooperating with this).

<script type="text/javascript">

	    function isValidEmail() {		
    		var email = document.getElementById("EmailField").value;
    		var submissionbutton = document.getElementById("submitbutton")
    		email = email.toLowerCase();
    		var AcceptedDomains = ["", ""];
    		var domfound = false;

		// Get email parts.  emailName is not used, but is there in case of... the future
		var emailParts = email.split("@"),
			emailName = emailParts[0],
			emailDomain = emailParts[1];

		for (i = 0; i < AcceptedDomains.length; i++){
			if(emailDomain == AcceptedDomains[i]) {
				submissionbutton.disabled = false;
				return true;				
		if (domfound == false) {
			alert("The email address you entered is invalid.  Please enter a valid or email address.")
			submissionbutton.disabled = true;
			return false;

I also changed the submit button to include the id tag:

<input type="submit" name="submit" value="<?php echo lg_portal_req_submitrequest ?>" id="submitbutton" disabled="true" />

Finally, I update the sEmail input with an id and OnBlur event:

<input type="text" id="EmailField" name="sEmail" size="40" maxlength="250" value="<?php echo $this->request_sEmail ?>" OnBlur="isValidEmail()" />


Great, thanks!

I tweaked the formatting a bit for you also.