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

  • Home
  • SEARCH
  • 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 8834455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:01:10+00:00 2026-06-14T09:01:10+00:00

I have a form I am working on and my validation JavaScript (jQuery &

  • 0

I have a form I am working on and my validation JavaScript (jQuery & jQuery validate plugin) works, up to a point. I’ve set up a jsfiddle to show it in it’s working state: http://jsfiddle.net/5Ukv2/

However, when I use the errorPlacement function/parameter, it breaks. The errors go where I specified, but multiple errors get added any time I update the input (ie, any keystroke), and when the entry is valid according to the JavaScript, the errors don’t get removed from my HTML: http://jsfiddle.net/5Ukv2/1/

Also, the validation starts happening as soon as I type into the input field; that issue is minor in comparison to the extra and unremoved error elements.

What am I doing wrong?

Code attached below for reference as well as in the jsfiddles. I commented a couple methods because they’re making ajax calls that won’t work here, but the validation acts the same.

HTML:

<form action="email_submit.php" method="post" name="enterForm" id="enterForm">
    <label for="email">Enter your email to play: 
    <input type="text" name="email" id="email" value=""  /> 
    <input type="submit" value="Enter" name="submit" class="submit" />       
</form>

JavaScript:

// JavaScript Document

$(function(){

$("#enterForm").validate({
    rules: {
        email: {
            email: true,
            required: true,
            remote: {url:"email_valid.php", async:false}
        }
    },
    messages:{
            email:{
                email: "Please enter a valid email address",
                required: "Please enter an email address",
                remote: "That is not a valid domain"
                }
    },
    submitHandler: function(form) {

        var formData = $('form').serialize();
        $.ajax({
          type: 'POST',
          url: "email_submit.php",
          data: formData,
          success: function(data){
              if(data.subscriber && data.valid_email)
                window.location = "calendar.html";
              else if( !data.valid_email)
                alert("Please enter a valid email");
              else if( !data.subscriber)
                alert("Open sign up form");
          },
          error: function(data){
              alert("e:" + data);
              console.log(data);
          },
          dataType: "JSON"
        });

        return false;
    },
    errorPlacement: function (error, element){
        if(  element.attr("name") == "email" ){
            error.insertAfter("#enterForm");
        } 
        else
            error.insertAfter(element);
    }               

    });

});
  • 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-14T09:01:13+00:00Added an answer on June 14, 2026 at 9:01 am

    It looks like the validator plugin expects the errors to be placed somewhere within the form element. When it’s looking for the “error” elements to hide or show, it must be restricting the search to the current form. This allows you to have multiple forms on the page, and changes in one form won’t affect the others.

    Arguably, this is probably a bug in the plugin. Here’s a modification of your form that works (see fiddle)

            <form action="email_submit.php" method="post" name="enterForm" id="enterForm">
                <label for="email">Enter your email to play:</label> 
                <input type="text" name="email" id="email" value=""  /> 
                <input type="submit" value="Enter" name="submit" class="submit" />             
            <div id="error_container"></div>
            </form>
    

    ​

    $(function(){
    
        $("#enterForm").validate({
            rules: {
                email: {
                    email: true,
                    required: true/*,
                    remote: {url:"email_valid.php", async:false}*/
                }
            },
            messages:{
                    email:{
                        email: "Please enter a valid email address",
                        required: "Please enter an email address"/*,
                        remote: "That is not a valid domain"*/
                        }
            },
            submitHandler: function(form) {
    
                var formData = $('form').serialize();
                $.ajax({
                  type: 'POST',
                  url: "email_submit.php",
                  data: formData,
                  success: function(data){
                      if(data.subscriber && data.valid_email)
                          window.location = "calendar.html";
                      else if( !data.valid_email)
                          alert("Please enter a valid email");
                      else if( !data.subscriber)
                          alert("Open sign up form");
                  },
                  error: function(data){
                      alert("e:" + data);
                      console.log(data);
                  },
                  dataType: "JSON"
                });
    
    
                return false;
            }, //uncomment this errorPlacement method
            errorPlacement: function (error, element){
                if(  element.attr("name") == "email" ){
                    error.insertAfter("#error_container");
                } 
                else
                    error.insertAfter(element);
            }               
    
    
        });
    
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a jquery form validation in the master page and it works fine
I have am using the jQuery validation plugin (1.8.1 from MS CDN) to validate
Picture of problem: http://tinypic.com/view.php?pic=2duwlsp&s=5 Description of problem: I have a jQuery form validation which
I have simple php validation form that is halfway working. If you leave the
I have a simple html form that I've added validation to using the JQuery
I have a JQuery modal popup form on a classic ASP page. It's set
I have a form with JavaScript validation. Upon there being an error, the submit
i have validation working on the form that is on the page. I have
I have a simple form that uses jQuery validation to notify the user of
I have jQuery validation working pretty well using a dialog for the error messages.

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.