I have an email id "emailid@gmail.com".I want to find out the number of characters before @ symbol and replace the email id containing alternate * character before @gmail.com by using javascript to view within the web page.Can any one help me to find out this problem?
javascript
<script>
function showemailid(){
var emailid="emailid@gmail.com";
emailid.replaceAt(1, "*");
emailid.replaceAt(3, "*");
emailid.replaceAt(5, "*");
alert(emailid);
}
String.prototype.replaceAt=function(index, character) {
return this.substr(0, index) + character + this.substr(index+character.length);
}
</script>//I want to show the mailid as e*a*l*d@gmail.com
I want find out the number of characters before @ symbol and then change the alternative character to '*' according to the length.
Thank you