Paul Rajs

Paul Rajs

  • 1.5k
  • 583
  • 88.5k

How to Mask first 6 digits as X when entering Aadhar Card No using jqu

Aug 20 2020 11:02 PM
Hi Developers ,
I have to Keep the div value without change first 6 digits as XXXXXX
Also need to edit if the user enter wrong Aadhar card number as well.
In the below code after release cursor or press tab action below
Textbox value : 8693-3764-2252
after enter tab = XXXX-XX64-2252
if i edit the text box value means the dvCCN value has been updated as same as XXXX-XX64-2252 ..
but it should be give the value without change first 6 digits as XXXXXX
This is my requirement ... if anyone know the solution kinldy suggest me
Am using the below Code
Jquery:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#txtCCN").on('blur', function () {
var CCNValue = $(this).val();
$('#dvCCN').html(CCNValue);
$(this).val(CCNValue.substring(0, 7).replace(/\d/g, "X") + CCNValue.substring(7));
});
});
</script>
Html
<body>
<input type="text" id="txtCCN" maxlength="14" />
<div id="dvCCN"></div>
</body>

Answers (2)