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 8197173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:41:16+00:00 2026-06-07T05:41:16+00:00

Here is my validation code: function validateEnquiryForm() { var x = document.forms[enquiry][name].value; if(x ==

  • 0

Here is my validation code:

  function validateEnquiryForm() {
      var x = document.forms["enquiry"]["name"].value;
      if(x == null || x == "" || x == "Name") {
          $('#name').removeClass('custom').addClass('error');
          $('.name-error').show();
          //return false;
      } else if(x !== null || x !== "" || x !== "Name") {
          $('#name').removeClass('error').addClass('custom');
          $('.name-error').hide();
      }
      var x = document.forms["enquiry"]["phone"].value;
      if(x == null || x == "" || x == "Phone Number") {
          $('#phone').removeClass('custom').addClass('error');
          $('.phone-error').show();
          //return false;
      } else if(x !== null || x !== "" || x !== "Phone Number") {
          $('#phone').removeClass('error').addClass('custom');
          $('.phone-error').hide();
      }
      var x = document.forms["enquiry"]["requirements"].value;
      if(x == null || x == "" || x == "Add any other extra requirements here...") {
          $('#requirements').removeClass('textarea-1').addClass('error');
          $('.requirements-error').show();
          //return false;
      } else if(x !== null || x !== "" || x !== "Add any other extra requirements here...") {
          $('#requirements').removeClass('error').addClass('custom');
          $('.requirements-error').hide();
      }
      var x = document.forms["enquiry"]["summary"].value;
      if(x == null || x == "" || x == "Summarise your project in a few key words...") {
          $('#summary').removeClass('custom').addClass('error');
          $('.summary-error').show();
          //return false;
      } else if(x !== null || x !== "" || x !== "Summarise your project in a few key words...") {
          $('#summary').removeClass('error').addClass('custom');
          $('.summary-error').hide();
      }
      var x = document.forms["enquiry"]["email"].value;
      var atpos = x.indexOf("@");
      var dotpos = x.lastIndexOf(".");
      if(atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= x.length) {
          $('#email').removeClass('custom').addClass('error');
          $('.email-error').show();
          //return false;
      } else if(atpos > 1 || dotpos > atpos + 2 || dotpos + 2 <= x.length) {
          $('#email').removeClass('error').addClass('custom');
          $('.email-error').hide();
      }
      $('.error-banner').effect("pulsate", {
          times: 2
      }, 1000);
      return false;
  }

When the code runs it checks all the fields to see if they are blank. If one or more are incorrectly filled in the .error-bannerpulses and individual messages are displayed. The problem is when the form is filled in correctly this banner still flashes. Could someone tell me where I am going 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-07T05:41:16+00:00Added an answer on June 7, 2026 at 5:41 am

    As far as I can tell, your function ends with this block, unconditionally:

    $('.error-banner').effect("pulsate", {
      times: 2
    }, 1000);
    return false;
    

    Maybe change it to:

    var valid = true;
    
    // in your error handling conditionals, set valid to false:
    if(x == null || x == "" || x == "Phone Number") {
        $('#phone').removeClass('custom').addClass('error');
        $('.phone-error').show();
        valid = false;
    } 
    
    ...
    
    if (!valid) {
      $('.error-banner').effect("pulsate", {
        times: 2
      }, 1000);
    }
    return valid;
    

    I have to agree with the majority of commenters that your approach leaves a lot of room for improvement, though.

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

Sidebar

Related Questions

I'm currently using the validation code listed here in an application. I'd like to
I have been following the validation for Entry boxes from here . The code
I coded, global mini form validation for jquery. This here; This code, All form
Now here is another problem.. my code: <script type=text/javascript> function validate_form () { if
I'm performing some custom js validation on my forms, triggered by submitting the form
I have the following block of code: $(document).ready(function(){ $(#form).submit(function(ev) { ev.preventDefault(); $.ajax({ type: POST,
I make a jquery validation, problem is here that this part from code first(first
I have been struggling with this jQuery Validation Plugin. Here is the code: <script
I'm facing a big issue IMO. First, here's my code: .bind('uploadSuccess', function(event, file, serverData){
Here is a validation script from a book I am learning, Why is escaping

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.