0
I am creating an online wallet to learn and I have a problem, I wanted to format my INPUT with a Coin mask and from what I saw Jquery is a good option. I saw a tutorial (in this case: http://blog.conradosaud.com.br/artigo/26) but it’s not working in my code..
body {
margin: 0px;
}
#navbar {
position: absolute;
top: 165px;
width: 100%;
height: 35px;
background-color: #59b210;
}
#coluna {
margin-top: 30px;
}
#coluna1 {
height: auto;
}
#coluna2 {
height: auto;
}
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Menu</title>
<link rel="stylesheet" href="css.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<!-- SCRIPT MASCARA $$ -->
<script src="https://igorescobar.github.io/jQuery-Mask-Plugin/js/jquery.mask.min.js"></script>
<script type="text/javascript">
$('.telefone').mask('(00) 0 0000-0000');
$('.dinheiro').mask('#.##0,00', {reverse: true});
$('.estado').mask('AA');
</script>
</head>
<body>
<div id="coluna">
<div class="container">
<div class="row">
<div class="col">
<div class="p-3 mb-2 bg-primary text-white"><h2>
<p class="text-center"> NOME </p>
</div>
<h2>
</div>
<div class="col">
<div class="p-3 mb-2 bg-danger text-white"><h2>
<p class="text-center"> NOME </p>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col">
<h6>
<p class="text-center"> Gastos Mensais</p>
</h6>
</div>
<div class="col">
<h6>
<p class="text-center"> Gastos Mensais</p>
</h1>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div id="coluna1" class="col">
<p class="text-center">Semana 1 <label for="dinheiro">R$</label> <input type="text" id="dinheiro" name="dinheiro" style="display:inline-block" />
<p class="text-center">Semana 2 <label for="dinheiro">R$</label> <input type="text" id="dinheiro" name="dinheiro" style="display:inline-block" />
<p class="text-center">Semana 3 <label for="dinheiro">R$</label> <input type="text" id="dinheiro" name="dinheiro" style="display:inline-block" />
<p class="text-center">Semana 4 <label for="dinheiro">R$</label> <input type="text" id="dinheiro" name="dinheiro" style="display:inline-block" />
<p class="text-center">Semana 5 <label for="dinheiro">R$</label> <input type="text" id="dinheiro" name="dinheiro" style="display:inline-block" />
</div>
<div id="coluna2" class="col">
<p class="text-center">Semana 1 <label for="dinheiro">R$</label> <input type="text" id="dinheiro" name="dinheiro" style="display:inline-block" />
<p class="text-center">Semana 2 <label for="dinheiro">R$</label> <input type="text" id="dinheiro" name="dinheiro" style="display:inline-block" />
<p class="text-center">Semana 3 <label for="dinheiro">R$</label> <input type="text" id="dinheiro" name="dinheiro" style="display:inline-block" />
<p class="text-center">Semana 4 <label for="dinheiro">R$</label> <input type="text" id="dinheiro" name="dinheiro" style="display:inline-block" />
<p class="text-center">Semana 5 <label for="dinheiro">R$</label> <input type="text" id="dinheiro" name="dinheiro" style="display:inline-block" />
</div>
</div>
</div>
</body>
</html>
Good afternoon, look at this lib here I use it and very simple to use. https://igorescobar.github.io/jQuery-Mask-Plugin/#examples follows a functional example https://gist.github.com/amadeujunior18/d793bb5b3a656c86ca1e3cee43e3bd5e
– Amadeu Junior