0

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

Gayathri Rajan
  • 369
  • 1
  • 6
  • 18
  • 1
    possible duplicate of [How do I redirect with Javascript?](http://stackoverflow.com/questions/4744751/how-do-i-redirect-with-javascript) – Quentin Sep 17 '15 at 07:12

1 Answers1

0

Using JSP tag inside script in JSP page :

 <script type="text/javascript">
                function showMessage(res)
                {
                    //code to show  or redirect the success.jsp.
                <%
                    response.sendRedirect("sucess.jsp");
                %>
                }
    </script>
Bhuwan Prasad Upadhyay
  • 2,916
  • 1
  • 29
  • 33