0

How to populate the last two digits after the mask? Example: XXXX99
So, when I key in the first digit should be 1XXX99

var autoPopulateNo = "\\9\\9"  //how to put this after the mask? example XXXX99

$("#number").inputmask({
"mask": "9999" + autoPopulateNo,
clearMaskOnLostFocus: false,
placeholder:"X",

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/jquery.inputmask.bundle.js"></script>
<form action="">  
  <div>
    <label for="number">Mask</label>
    <input id="number" type="text"/>
  </div>
</form>

2
  • 3
    Welcome back, stackoverflow.com/questions/44818443/… Commented Jun 29, 2017 at 9:15
  • how about if the last two digits number is 99 instead of 56? Commented Jun 29, 2017 at 9:21

1 Answer 1

1

The thing is so simple.You just append your variable with mask.

var autoPopulateNo = 56  
$("#number").inputmask({
"mask": "9999"+autoPopulateNo,
clearMaskOnLostFocus: false,
placeholder:"X",

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/jquery.inputmask.bundle.js"></script>
<form action="">  
  <div>
    <label for="number">Mask</label>
    <input id="number" type="text"/>
  </div>
</form>

Sign up to request clarification or add additional context in comments.

2 Comments

could you try this? var autoPopulateNo = 99
I will check and tell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.