Hello, I'm trying to change the placeholder of an input by checking between 2 input radio values. Below is the js I tried to mount and the html.
$(document).ready(function () {
$('#tipousuario').prop('checked',function () {
if($(this).val() === '1'){
$(this).attr({placeholder:"Insira seu CNPJ",maxlenght:"14"});
}
if($(this).val() ==='2'){
$(this).attr({placeholder:"Insira seu CRC",maxlenght:"8"});
}
});
});
<div class="col-lg-7">
<div class="form-group">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="tipouser" id="tipousuario" value="1" checked>
<label class="form-check-label" for="inlineRadio1">CNPJ</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="tipouser" id="tipousuario" value="2">
<label class="form-check-label" for="inlineRadio2">CRC</label>
</div>
</div>
<div class="form-group">
<input type="text" required="required" class="form-control" maxlength="14" name="usuario" id="InputUsuario" pattern="[0-9]+$" placeholder="Usuário">
<small class="text-muted">Apenas números</small>
</div>