Professional Documents
Culture Documents
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title>Tratamento de formulários</title>
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z"
crossorigin="anonymous">
</head>
<body>
<form class="form-horizontal">
<fieldset>
</div>
<div class="col-md-5"><span id="tratamodelo"></span></div>
</div>
</div>
</div>
<br/>
<div class="col-md-5"><span id="trataano"></span></div>
</div>
</div>
<div class="col-md-5"><span id="trataemail"></span></div>
</div>
<!-- COLOR -->
<div class="form-group" id="cordiv">
<label class="col-md-4 control-label" for="corselect">Cor do Veículo</label>
<div class="col-md-1">
<input id="corselect" name="corselect" type="color" class="form-control input-sm"
required value="#000000" onchange="trocacor();">
</div>
</div>
<!-- RANGE - VALOR -->
<div class="form-group">
<label class="col-md-4 control-label" for="valorrange">Valor de Lucro</label>
<div class="col-md-5">
<b>5.000 <input id="valorrange" name="valorrange" type="range" class=" input-sm"
min="5000" max="25000" onchange="exibelucro();"> 25.000</b>
</div>
<div class="col-md-4">
Valor do Lucro: R$ <span id="
</fieldset>
</form>
</body>
<script type="text/javascript">
document.getElementById('cordiv').style =
"background-color: "+ document.getElementById("corselect").value+";";
function trocacor(){
document.getElementById('cordiv').style =
"background-color: "+ document.getElementById("corselect").value+";";
}
document.getElementById('lucrovalor').innerHTML =
parseFloat(document.getElementById('valorrange').value).toFixed(2);
function exibelucro(){
document.getElementById('lucrovalor').innerHTML =
parseFloat(document.getElementById('valorrange').value).toFixed(2);
}
function validaano(){
let ano = document.getElementById("datatxt");
window.alert("Ano inválido");
document.getElementById("trataano").innerHTML = "de 2000 à 2020";
document.getElementById("trataano").style = "color:red;";
ano.focus();
}
}
function validamodelo(){
let modelo = document.getElementById("modelotxt").value;
function validafabricante(){
if(document.getElementById("fabricanteselect").value === "0"){
document.getElementById("tratafabricante").innerHTML =
"Fabricante é obrigatório.";
document.getElementById("tratafabricante").style =
"color: red;";
} else {
document.getElementById("tratafabricante").innerHTML =
"";
}
}
function validaemail(){
/*alert("oi");
var email = document.getElementById("emailtxt").value;
var exclude=/[^@-.w]|^[_@.-]|[._-]{2}|[@.]{2}|(@)[^@]*1/;
var check=/@[w-]+./;
var checkend=/.[a-zA-Z]{2,3}$/;
/*document.getElementById("trataemail").innerHTML =
"Fabricante é obrigatório.";
document.getElementById("trataemail").style =
"color: red;";
}else{
//document.getElementById("trataemail").innerHTML ="";
}*/
}
</script>
</html>
<!--
Usando o evento onchange faça aparecer o valor selecionado como lucro no range e a
cor selecionada no color deverá preencher a div deste campo.
-->
<!--
USANDO O ONCHANGE valide o formulário em tempo real.
MODELO - precisa avisar que:
- não pode ficar vazio (OBRIGATÓRIO).
- precisa ter mais de 1 caractere.
ANO
- Precisa ser maior que 2000 e menor que o ano atual;
- não pode ficar vazio (OBRIGATÓRIO).
FABRICANTE:
- não pode ser o SELECIONE;
-->