How to make a script in pug engine

-1

I'm trying to make a script that contains a function in the pug engine, but I can not get it to call when the user submits the form, can anyone help me? Here is the code:

html
  head
    title= message
    script.
      funtion validator(){  
        alert("teste");
      }
  body
    h1= message
    form(method ="post", action="/cadastrar/marca")
      input(type="text", name="descricao", id="descricao")
      input(type="submit", onclick="return validator()")
    
asked by anonymous 15.08.2018 / 15:09

1 answer

0

I found the solution, the problem was really the word "function" that was wrong, thank you very much for the attention, follow the correct code:

html
  head
    title= message
    script(src="validator.min.js")
    script.
      function teste(){
        alert("Teste")
      }
  body
    h1= message
    form(method ="post", action="/cadastrar/marca", onclick="return teste();")
      input(type="text", name="descricao")
      input(type="submit", value="save")
    
15.08.2018 / 16:09