1
Hello, I’m trying to change the placeholder of an input by checking between 2 radio input values. Below is the js I tried to mount and 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>
Hello Rafael! Until today you have not marked an answer with . It is important for the community that the questions are finalized, and for this we need to mark an answer. If none of you answered it, you can ask questions to the AR (author of the answer), but do not leave questions open because it harms the purpose of the site. Obg!
– Sam