Validation in form with the database

0

Good afternoon! I used this code for a form that is in html , however in this case, I'm using a framework called web2py, which generates form through the db file. I need to validate the fields, but the html that web2py generates when it takes the data that is in the db file does not have mame="nome" or id="nome" , nor form , nor the button to use the function click . Would there be some other way to get it other than% s of% or% of% of name or button?

using the button with a id (no form nor id )

var botao = document.getElementsById("btn"); 
botao.addEventListener("click", function () {
    var nome = document.getElementById("Cliente_Nome");
    var telefone = document.getElementById("Cliente_Telefone");
    var email = document.getElementById("Cliente_Email");
    var cpf = document.getElementById("Cliente_CPF_ou_CNPJ");

    nome.setCustomValidity(nome.value == "" ? "Informe Corretamente o Nome" : "" );
    telefone.setCustomValidity(telefone.value == "" ? "Informe Corretamente o Telefone com DDD" : "" );
    email.setCustomValidity(email.value == "" ? "Informe Corretamente o Email" : "" );
    cpf.setCustomValidity(cpf.value == "" ? "Informe Corretamente o CPF ou CNPJ" : "" );

}); 

In this case using id , with name (tbm does not have form nor name no name )

function validacao() {
    var formulario = document.register;
    var nome = formulario.nome;
    var email = formulario.email;

    if (nome.value == "") {
        alert("Insira um nome válido.");
        return false;
    }

    if(email.value.indexOf("@") == -1 || email.value.indexOf(".") == -1) {
        alert("Insira um email válido");
        return false;
    }

    return true;
}
    
asked by anonymous 01.10.2018 / 21:00

0 answers