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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:17:02+00:00 2026-05-31T18:17:02+00:00

I am trying to write my own form validation script with jQuery. However, I

  • 0

I am trying to write my own form validation script with jQuery.

However, I can’t seem to get it to work, It’s probably something minor but I can’t find the cause of the problem.

Also, I have only just started using jQuery an I am looking for a good syntax checker. Can anyone recommend one?

$(document).ready(function() {
  $('.error').toggle();
  });


//when the button is clicked

$(".button").click(function() {
        // validate and process form
        // first hide any error messages
    $('.error').hide();

      var name = $("input#name").val();
        if (name == "") {
      $("label#name_error").show();
      return false;
    }

          var name = $("input#email").val();
        if (name == "") {
      $("label#name_error").show();
      return false;
    }

          var name = $("input#subject").val();
        if (name == "") {
      $("label#name_error").show();
      return false;
    }

          var name = $("textarea#message").val();
        if (name == "") {
      $("label#name_error").show();
      return false;
    }

    var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;

        $.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Contact Form Submitted!</h2>")
        .append("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
        $('#message').append("<img id='checkmark' src='images/check.png' />");
        });
      }
     });
    return false;
    });
});
  • 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-05-31T18:17:03+00:00Added an answer on May 31, 2026 at 6:17 pm

    Make sure you include jQuery.validate.min.js or jquery.validate.unobtrusive.min.js (cant remember off top of my head) file(s) and then validate inside jQuery like this:

    $('.button').click(function () {
    if ($('form').valid()) {
        //do saving stuff
    } else {
        //errors on form - let user correct them
    }
    

    });

    As far as Syntax checker, not sure what platform your developing on but Im using Visual Studio 2010 and if you include the js files then VS2010 gives intellisense which highlights issues.

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

Sidebar

Related Questions

I have been trying to write my own diff3 wrap script for SVN and
Im trying to write something to get my images to show correctly. I have
Hi Stackoverflow people, I am trying to write my own contact form in Django,
I am trying to write my own JVM. Can you point me to some
I'm trying to write my own jQuery plugin. My goal is to attach it
I'm trying to write a jQuery script (I have never written one before and
I'm trying to write my own toy My Toy Language -> MSIL compiler in
I am trying to write our own RIA services provider to expose data from
I have been trying to write a small app with its own option windows.
(Edit: randrange is just random.randrange, I didn't write my own RNG) I'm trying to

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.