anchor.diff:                  } else {
                       e.preventDefault();
   
  +                    var isEmailUsernameEnabled = JSON.parse("<%= isEmailUsernameEnabled %>");
  +                    var tenantName = getParameterByName("tenantDomain");
                       var userName = document.getElementById("username");
                       var usernameUserInput = document.getElementById("usernameUserInput");
  -                    var tenantName = getParameterByName("tenantDomain");
   
                       if (usernameUserInput) {
  -                        userName.value = usernameUserInput.value.trim();
  +                        var usernameUserInputValue = usernameUserInput.value.trim();
  +
  +                        if (tenantName && tenantName !== "null") {
  +
  +                            if (isEmailUsernameEnabled) {
  +
  +                                if (usernameUserInputValue.split("@").length <= 1) {
  +                                    var errorMessage = document.getElementById("error-msg");
  +
  +                                    errorMessage.innerHTML = "Invalid Username. Username has to be an email address.";
  +                                    errorMessage.style.display = "block";
  +
  +                                    return;
  +                                }
  +
  +                                if (usernameUserInputValue.split("@").length === 2) {
  +                                    userName.value = usernameUserInputValue + "@" + tenantName;
  +                                }
  +                                else {
  +                                    userName.value = usernameUserInputValue;
  +                                }
  +                            } else {
  +                                if (usernameUserInputValue.split("@").length > 1) {
  +                                    userName.value = usernameUserInputValue;
  +                                } else {
  +                                    userName.value = usernameUserInputValue + "@" + tenantName;
  +                                }
  +
  +                            }
  +                            
  +                        } else {
  +                            userName.value = usernameUserInputValue;
  +                        }
                       }
   
                       if (userName.value) {
  
positive.code: <%@ page import="javax.ws.rs.core.Response" %>
  <%@ page import="static org.wso2.carbon.identity.core.util.IdentityUtil.isSelfSignUpEPAvailable" %>
  <%@ page import="static org.wso2.carbon.identity.core.util.IdentityUtil.isRecoveryEPAvailable" %>
  <%@ page import="static org.wso2.carbon.identity.core.util.IdentityUtil.getServerURL" %>
  <%@ page import="org.apache.commons.codec.binary.Base64" %>
  <%@ page import="org.apache.commons.text.StringEscapeUtils" %>
  
negative.code: <%@ page import="org.wso2.carbon.identity.core.ServiceURLBuilder" %>
  
  <jsp:directive.include file="includes/init-loginform-action-url.jsp"/>
  
  <%
      String emailUsernameEnable = application.getInitParameter("EnableEmailUserName");
      Boolean isEmailUsernameEnabled = false;
  
      if (StringUtils.isNotBlank(emailUsernameEnable)) {
          isEmailUsernameEnabled = Boolean.valueOf(emailUsernameEnable);
      } else {
          isEmailUsernameEnabled = isEmailUsernameEnabled();
      }
  %>
  
  <%
      String proxyContextPath = ServerConfiguration.getInstance().getFirstProperty(IdentityCoreConstants
              .PROXY_CONTEXT_PATH);
  