ola boa noite…
to com esse formulario simples so que eele nao esta autenticando digamos assim pois ele devia mostrar a msg de tais campos sao obrigatorio
aki esta o codigo desde ja grato pela ajuda
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Pagina de formulario</title>
<style type="text/css">
.form{
background: red;
font-family: fantasy;
font-weight: bold;
font-style: italic;
color: green;
font-size: 24px;
}
</style>
<script type="text/javascript">
function validar(){
var i=document.getElementById("sexo").selectedIndex;
var tst=true;
var saida="os campos sao obrigatorios ";
if(document.getElementById("nome").value==""){
saida += "\nNome";
tst=false;
}
if(document.getElementsByName("sexo").options[i].value==""){
saida="\nsexo";
tst=false;
}
if(document.getElementById("sobrenome").value==""){
saida += "\nsobrenome";
teste = false;
}
if(tst){
alert("daddos salvos ok!!");
return true;}
else{
alert(saida);
return false;
}
</script>
</head>
<body >
<form id="formulario 1" name="formulario 1">
<table>
<tr>
<td class="form">
nome:
</td>
<td class="form">
<input type="text" name="nome" id="nome">
</td>
</tr>
<tr>
<td class="form">
sobrenome:
</td>
<td class="form">
<input type="text" name="sobrenome" id="sobrenome ">
</td>
</tr>
<tr>
<td class="form">
sexo:
</td>
<td class="form">
<select id="sexo" name="sexo">
<option> -------Selecione--------</option>
<option value="masculino"> Homem</option>
<option value="feminino"> mulher</option>
</select>
</td>
</tr>
<tr>
<td>
decricao pessoal:
</td>
<td>
<textarea class="form" rows="30px" cols="47px" id="descricao" name="descricao" >
</textarea>
</td>
</tr>
<td>
<input type="submit" value="guardar" id="guardar" name="guardar" onclick="validar();">
</td>
<td class="form">
<input type="reset" name="reset" id="reset " value="limpar">
</td>
</tr>
</table>
</form>
</body>
</html>
