2
Good morning, all right?
I am starting in Javascript and I need to validate all the fields in the form below through this. I was able to validate the first 6 fields, radio and checkbox are missing.
Some help?
Follows code below:
<!DOCTYPE html>
<html lang="pt-br" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>Freedom/C></title>
    <link rel="stylesheet" type="text/css" href="Freedom.css"/>
    <script language="JavaScript" type="text/javascript">
        function validar() {
            var Setor = fOcorrencia.Setor.value;
            var Resp = fOcorrencia.Resp.value;
            var TipoO = fOcorrencia.TipoO.value;
            var RespApOc = fOcorrencia.TipoO.value;
            var Descricao = fOcorrencia.Descricao.value;
            var Plano = fOcorrencia.Plano.value;
            if (Setor == "") {
                alert("Preencha todos os campos");
                return false;
            }
            if (Resp == "") {
                alert("Preencha todos os campos");
                return false;
            }
            if (TipoO == "") {
                alert("Preencha todos os campos");
                return false;
            }
            if (RespApOc == "") {
                alert("Preencha todos os campos");
                return false;
            }
            if (Descricao == "") {
                alert("Preencha todos os campos");
                return false;
            }
            if (Plano == "") {
                alert("Preencha todos os campos");
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<div>
    <h1>Controle de Qualidade</h1>
    <h2 align="center">Cadastro de Ocorrências</h2>
</div>
<form method="post" id="fOcorrencia" name="fOcorrencia" action="mailto:[email protected]">
    <fieldset>
        <legend>Descreva</legend>
        <p><label for="cSetor">Setor:</label><input type="text" size="70" maxlength="70" name="Setor" id="cSetor"/></p>
        <p><label for="cResp">Responsável:</label><input type="text" size="70" maxlength="70" name="Resp" id="cResp"/></p>
        <p><label for="cTipoO">Tipo de ocorrência:</label><input type="text" size="70" maxlength="70" name="TipoO" id="cTipoO"/></p>
        <p><label for="cRespApOc">Responsável pela aprovação da ocorrência:</label><input type="text" name="RespApOc" size="70" maxlength="70" id="cRespApOc"/></p>
        <p><label for="cDescricao">Descrição da ocorrência:</label><textarea name="Descricao" id="cDescricao" cols="70" rows="5"></textarea></p>
        <p><label for="cPlano">Plano de ação:</label><textarea name="Plano" id="cPlano" cols="70" rows="5"></textarea></p>
    </fieldset>
    <fieldset>
        <legend>Tipo</legend>
        <input type="radio" name="Tipo" id="cDisp"/><label for="cDisp">Disposição</label>
        <input type="radio" name="Tipo" id="cCorr"/><label for="cCorr">Correção</label>
    </fieldset>
    <fieldset>
        <legend>Natureza</legend>
        <label><input type="checkbox" value="Prod"/>Produção</label>
        <label><input type="checkbox" value="Admin"/>Admnistrativo</label>
        <label><input type="checkbox" value="Amb"/>Ambiental</label>
    </fieldset>
    <input type="submit" onclick="return validar()" value="Enviar Ocorrência"/>
</form>
</body>
</html>