title: Mask credit card number except first and last four digits on user input
body: <p>I have a requirement where i need to mask the digits of a credit card number except the first and last four using javascript.</p>
  <p>The credit card value will be captured as part of just one input box and i need to mask the digit after the user has entered the value</p>
  <p>ex:</p>
  <pre><code>Suppose the credit card number is :
  4000 5000 6000 7000
  
  while the user enters the input the first four digits i.e.
  4000 will be visible but while the user enters the digit '6' 
  it should be visible for some time and then get masked.
  
  The output after entering all the digits would need to look like:
  4000 XXXX XXXX 7000
  
  Also i would need the actual card number to be captured separately for processing
  </code></pre>
  <p>I have found solutions to mask the card number after the user has entered the entire card number but nothing on doing it while the user enters the value using some javascript event.As i am new to javascript some guidance on how i could accomplish this would be really helpful</p>