4
I am implementing a jquery form, and I want that when Valida runs and class error is added to the label leaving the red font, I will send a picture representing how I want.
<html>
<head>
<title>Como Validar um Formulário dinamicamente com jQuery</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript">
$(function () {
$("#my-form").validate({
focusCleanup: true,
errorLabelContainer: "input .labell",
errorElement: "div",
rules: {
nome: {
minlength: 3,
maxlength: 50
},
empresa: {
minlength: 4
}
},
messages: {
nome: {
required: "",
minlength: "Insira seu nome completo!"
},
cpf: {
required: ""
},
empresa: {
required: "",
minlength: "Preencha no mínimo 4 caracteres!"
}
}
});
});
</script>
</head>
<body class="container">
<form class="text-uppercase" role="form" id="my-form" method="post" action="add_pess.php"><br><br>
<div class="row">
<div class="col-md-12">
<label class="labell" id="lb_nome" for="nome">Nome Completo:</label>
<input type="text" class="form-control required" id="nome" name="nome" placeholder="Digite seu nome completo">
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<label id="lb_cpf" class="labell" for="cpf">CPF:</label>
<input type="tel" class="form-control required" id="cpf" name="cpf" placeholder="Digite o CPF">
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<label id="lb_empresa" class="labell" for="empresa">Empresa:</label>
<input type="text" class="form-control required" id="empresa" name="empresa" placeholder="Digite o nome da empresa">
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<label>Relacionamento:</label>
<select name="tipo" id="tipo" class="form-control">
<option value="CLIENTE">CLIENTE</option>
<option value="FORNECEDOR">FORNECEDOR</option>
<option value="PARCEIRO">PARCEIRO</option>
<option value="OUTRO">OUTRO</option>
</select>
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<label for="ob">Observações:</label>
<textarea rows="5" class="form-control" id="ob" name="ob" placeholder="Se caso haver alguma observação digite aqui"></textarea>
</div>
</div><br>
<div class="text-right col-md-12">
<button id="submit" type="submit" class="btn btn-primary">Enviar</button>
</div><br>
</form>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" ></script>
</body>
</html>
Your code is giving error when executing. Could fix it?
– Hugo Leonardo
{ "message": "Uncaught Syntaxerror: Unexpected token <", "filename": "http://stacksnippets.net/js", "lineno": 38, "colno": 9 }
– Hugo Leonardo
Yes I’ll fix it.
– Sr. Bigode