I've got some simple code right here:
$('#username').on('input paste', function(){
if($(this).val().length >3 && $(this).val().length <= 16){
$(this).css('background-image', 'url(images/register_related/input_box_success.png)');
usr = 1;
dat_usr = $('#username').val();
console.log('Correct Stuff Username');
}
else if($(this).val().length == 0){
$(this).css('background-image', 'url(images/register_related/input_box_rq.png)');
usr = 0;
}
else {
$(this).css('background-image', 'url(images/register_related/input_box_error.png)');
usr = 0;
}
});
Later on I change the id of #username to #password:
$('#username').attr({id:'password', type:'password'});
When checking source of the page, it shows as password, not username, but the function used for #username still applies. Why is this happening and how can it be avoided?