Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9092281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:48:12+00:00 2026-06-16T22:48:12+00:00

I have some form with jquery validantion, and i want to display all errors

  • 0

I have some form with jquery validantion, and i want to display all errors in same div element above the form.

i try do this, but is not working:

$("#contactForm").validate({
            rules: {
                assunto: { required: true },
                nome: { required: true, minlength: 2 }, 
                email: { required: true, email: true },
                telefone: { required: true },
                mensagem: { required: true }
            }, 
            errorPlacement: function(error, element) {
                if (element.attr("name") == "assunto" || element.attr("name") == "nome" || element.attr("name") == "email" || element.attr("name") == "telefone" || element.attr("name") == "mensagem" )
                //here i think i want to insert the location but i don't know how!
            else
                //here i think i want to insert the location but i don't know how!
            },

            messages: { 
                assunto: {required: 'É necessário escolher um assunto'},
                nome: { required: 'É necessário preencher o campo nome', minlength: 'No mínimo 2 letras' }, 
                email: { required: 'Informe seu email', email: 'Informe um Email válido' },             
                telefone: { required: 'Informe seu Telefone' },
                mensagem: { required: 'Escreva sua Mensagem' }
            },

            submitHandler: function(form){
                var dados = $( form ).serialize();  
                $.ajax({  
                    type: "POST",  
                    url: "enviafaleconosco.asp",
                    data: dados,  
                    success: function( data )  
                    {  
                        alert("Obrigado! Seu contato foi enviado com sucesso. Breve retornaremos!");
                        $("#contactForm")[0].reset();                   
                    }  
                });  
                return false;  
            }           
    });

what i’m doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:48:14+00:00Added an answer on June 16, 2026 at 10:48 pm

    You have a Syntax error here:

    errorPlacement: function(error, element) {
                    if (element.attr("name") == "assunto" || element.attr("name") == "nome" || element.attr("name") == "email" || element.attr("name") == "telefone" || element.attr("name") == "mensagem" )
                    //here i think i want to insert the location but i don't know how!
                    else
                    //here i think i want to insert the location but i don't know how!
                },
    

    If the if and else don’t have nothing inside you must add the curly brackets {} to close them:

    errorPlacement: function(error, element) {
                    if (element.attr("name") == "assunto" || element.attr("name") == "nome" || element.attr("name") == "email" || element.attr("name") == "telefone" || element.attr("name") == "mensagem" ){
                    //here i think i want to insert the location but i don't know how!
                    } else {
                    //here i think i want to insert the location but i don't know how!
                    }
                },
    

    It is also a good practice to always add the curly brackets to if blocks, even if they are single line

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problems sending an id though jquery. I have a form select
I have a form where I remove some CKeditor instantiated textareas with jQuery's .remove()
Please help! I have some form elements in a div on a page: <div
I have some data in this form (dictionary): Value0 Text1 Value1 Text2 Value2 Text3
I am creating a form validation in jQuery, but I have some problems; First
I have an HTML form where I want to add some validation logic. In
I have a form with jquery validation. I have some custom rules, but they
I have some *Type form classes and a forms.html.twig to customize form appearance. By
In my form I have some TextBoxes. Once the value of TextBox is changed
I have some Javascript attached to the Service Activity form which fires OnLoad. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.