Boa tarde pessoal...
Eu estou desenvolvendo uma "agenda", porém não estou conseguindo colocar o campo "nome" como preenchimento obrigatório.
Peço ajuda!..
<?php include("conecta.php"); ?>
<html>
<head>
<meta charset="utf-8">
<title>Agenda Pessoal</title>
<script type="text/javascript">
function validar(){
var nome = formulario-principal.nome.value;
if(nome == ""){
alert('Preencha o campo nome.');
formulario-principal.nome.focus();
return false;
}
}
</script>
</head>
<body>
<h1>Agenda Pessoal</h1>
<form name="formulario-principal" action="adiciona-cliente.php" method="post">
<div id="container-botoes">
<input type="button" name="btn-incluir" value="Incluir">
<input type="button" name="btn-cancelar" value="Cancelar">
<input type="button" name="btn-alterar" value="Alterar">
<input type="submit" name="btn-gravar" value="submit" onclick=" return validar()">
<input type="button" name="btn-limpar" value="Limpar">
<input type="button" name="btn-excluir" value="Excluir">
<input type="button" name="btn-sair" value="Sair">
</div>
<div id="mensagem_de_cadastramento">
<h4>Cliente cadastrado com susseco!</h4>
</div>
<table border="3" name="campos">
<tbody>
<tr>
<td>Nome:</td>
<td><input class="estilotextarea" type="text" name="nome" size="40" autofocus placeholder="Digite o nome" onFocus="this.style.backgroundColor='#FFFBDD'" onblur="this.style.backgroundColor=''"><br/></td>
</tr>
<tr>
<td>Endereço:</td>
<td><input type="text" name="endereco" size="40" placeholder="Digite o endereço"onFocus="this.style.backgroundColor='#FFFBDD'" onblur="this.style.backgroundColor=''"><br/></td>
</tr>
<tr>
<td>Telefone</td>
<td><input type="text" name="telefone" size="15" placeholder="(00)0000-0000" onFocus="this.style.backgroundColor='#FFFBDD'" onblur="this.style.backgroundColor=''"><br/></td>
</tr>
</tbody>
</table>
</form>