Search code examples
javascriptjquerydrupaldrupal-7drupal-6

I want to display the Email Id and Mobile number in masked format in drupal7? Suggestions needed


Example.

raju327@gmail.com
9999888877

Output

rajuXXX@gmail.com 
999XXXX877

And also core i want to use the OTP functionality to be fixed with button click OTP password only customer should change username and password.


Solution

  • Check working example,

    $(document).ready(function () {
       MobEncrypt();
       EmailEncrypt()
    });
    
    function MobEncrypt() {
    var value = '9999888877';
        // make a string with x-characters
        var x = new Array(value.length - 3).join('X');
        // join this string with the tail of the value, and replace it
        alert(x + value.substr(value.length - 3));
    }
    
    function EmailEncrypt() {
    var value = 'raju327@gmail.com';
        // make a string with x-characters
        var x = new Array(value.length - 5).join('X');
        // join this string with the tail of the value, and replace it
        alert(x + value.substr(value.length - 5));
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>