0
I would like to know how to remove all blanks from one textarea
.
I have a field textarea
that copies the value to a second field textarea
, would like to perform a function that removes space or line break. My function did not work.
$(function () {
$('#texto').on('input', function () {
var texto = $(this).val();
function trim(texto) {
return texto.replace(/^\s+|\s+$/g,"");
}
$('#convertido1').val(texto);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container" style="margin-top:100px">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="textoOriginal">Insira seu Texto</label>
<textarea class="form-control" id="texto" class="texto" rows="3"></textarea>
</div>
</div>
<div class="col-md-6">
<label for="textoConvertido">Insira seu Texto</label>
<textarea class="form-control" id="convertido1" name="convertido1" rows="3"></textarea>
</div>
</div>
</div>