Inorder to get the email address text before "@" in javascript use the below code.
emailAdr.substring(0, emailAdr.indexOf("@"))
Example
<html>
<script type="text/javascript" language="javascript">
var emailSubStrBeforeAtSymbol = ''
function GetEmailSubStringBeforeAtSymbol(emailAdr) {
emailSubStrBeforeAtSymbol = '';
if(emailAdr.indexOf("@") != -1)
{
emailSubStrBeforeAtSymbol = emailAdr.substring(0, emailAdr.indexOf("@"));
}
}
GetEmailSubStringBeforeAtSymbol('dotnetmirror@sampledomain.com')
alert(emailSubStrBeforeAtSymbol);
GetEmailSubStringBeforeAtSymbol('invalidemail');
alert(emailSubStrBeforeAtSymbol);
</script>
<body>Get the text before "@" in javascript </body>
</html>
output:
dotnetmirror (dotnetmirror@sampledomain.com)
'' (invalidemail)