Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
136
rated 0 times [  140] [ 4]  / answers: 1 / hits: 27741  / 12 Years ago, wed, october 24, 2012, 12:00:00

I want to show all the input as stars when the user types in the credit card field except the last four digits which I want to show as numbers. I used jQuery masking but it is not giving me desired result.


More From » jquery

 Answers
14

you can use multiple inputs, for example:



<script type=text/javascript>
$(function () {
$(.card-number input[type='password']).keyup(function (event) {
var len = $(this).val().toString().length;
if (len == 4) {
$(this).next().focus();
}
});

$(.card-number input[type='button']).click(function () {
var number = 0;
$(.card-number input).not(input[type='button']).each(function (index, element) {
number += $(element).val();
});
alert(number);
});
});



</script>

<!-- ####-####-####-#### -->
<div class=card-number >
<input type=password value= maxlength=4 />
<input type=password value= maxlength=4 />
<input type=password value= maxlength=4 />
<input type=text value= maxlength=4 />
<input type=button value=go />
</div>

[#82381] Monday, October 22, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
josefn

Total Points: 251
Total Questions: 93
Total Answers: 84

Location: Senegal
Member since Fri, Aug 21, 2020
4 Years ago
;