Hide characters in HTML?

I am writing an application in Django and I need to show some information and hide something like if the contact number is "9087654321", then I want to show it as "908 ***** 21". I do not know java script. Since I can only do this with HTML and CSS. I am new, so please be generous and light. Thank you in advance.

+4
source share
3 answers

These are two ways to deal with this: the first is the one that Eric Krali introduced - using Javascript.

Secondly, Python is used for this. You can write a method in your view that will hide this sensitive data for a user who is not registered, etc.

Then just use in Python:

no = list(no)
no[3:-2] = "*" * len(no[3:-2])
+1
source

This should work:

var str = "9087654321";
str.slice(0,3) + str.slice(3,-2).replace(/./g,'*') + str.slice(-2);
// "908*****21"

Works with every contact number.

+2
source

You can try the following:

var contactNumber = "9087654321";
var maskedNumber = contactNumber.substr(0, 3) + Array(contactNumber.length - 4).join('*') + contactNumber.substr(contactNumber.length - 2, 2);

It takes the first 3 and last 2 numbers and fills the gap with asterisks (asterisk).

Result maskedNumberwill be908*****21

For security reasons, I would recommend PatNowak's answer as it hides the contact number until it is sent to the client.

+1
source

Source: https://habr.com/ru/post/1622726/


All Articles