HTML
<div>
<input type='text' id='ccType' name='ccType'/>
<ul style="list-style-type: none;" class="cards">
<li class="visa"></li>
<li class="visa_electron"></li>
<li class="mastercard"></li>
<li class="maestro"></li>
</ul>
</div>
<div class="form-group">
<label class="control-label">Card Number</label>
</div>
<div class="fake-input">
<input type="text" placeholder="Card Number" id="ccnumber" name="ccnumber" class="form-control"/>
<img id="cc" src="" width=30 />
</div>
I have this html which has a text field in which when card number is typed it will detect the number whether its visa/maestro/whatever and set the value to ccType element.I have a javascript JS
$( window ).load(function() {
$("#ccType").on('change', function () {
var ccType = $(this).val();
if (ccType == "visa") {
$('#cc').attr('src', 'http://www.fethr.com/webapp/images/visa.png');
}
if (ccType == "maestro") {
$('#cc').attr('src', 'http://www.fethr.com/webapp/images/maestro.png');
}
if (ccType == "mastercard") {
$('#cc').attr('src', 'http://www.fethr.com/webapp/images/mastercard.png');
}
if (ccType == "visa_electron") {
$('#cc').attr('src', 'http://www.fethr.com/webapp/images/visaelectron.png');
}
})
});
which i made to set the image inside the text field.I have the following css for the img and text field CSS
.fake-input { position: relative; }
.fake-input input { border:none: background:#fff; display:block; width: 100%; box-sizing: border-box }
.fake-input img { position: absolute; top: 9px; right: 5px }
But the image script doesnt seems working or I cant show image inside the text field? Any help
FIDDLE