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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:38:35+00:00 2026-06-06T19:38:35+00:00

I have a simple form at my site which sends it data via Ajax

  • 0

I have a simple form at my site which sends it data via Ajax and then slides a message down. The sending works fine, and the message slides down, but the validation part does not work. I want it to show an alert if user doesn’t fill anything at all to the field.

Here’s the whole code:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Coming Soon!</title>

        <!-- Our CSS stylesheet file -->
        <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" />
        <link rel="stylesheet" href="assets/css/styles.css" />
        <link rel="stylesheet" href="assets/countdown/jquery.countdown.css" />

        <!--[if lt IE 9]>
          <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
        <!-- JavaScript includes -->
        <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
        <script src="assets/countdown/jquery.countdown.js"></script>
        <script src="assets/js/script.js" charset="UTF-8"></script>
        <script>

        $(function() {
    $(".submit").click(function() {
      var sposti = $("input#sposti").val();
        if (sposti == "") {
        alert ('Kirjoita nyt jotain herranjestas tuohon!');
        return false;
      }
var dataString = $('#formi').serialize();
  //alert (dataString);return false;
  $.ajax({
    type: "POST",
    url: "mailer.php",
    data: dataString,
    success: function() {
     $("#thanks").slideDown('slow');
    }   


  });
  return false;

    });
  });



        </script>


</head>

    <body>
    <div id="thanks" style="width:100%; height:100px; background:url('../img/page_bg_center.jpg') no-repeat center center;
    position:absolute; top:0px; border-bottom:2px solid black; text-align:center; display:none;"><span style="position:absolute; top:30px;">Kiitos! Saat tiedon kun sivusto avautuu :)</span></div>

        <div id="countdown"></div>

        <p id="note"></p>
        <p style="text-align:center; color:#666666; text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.3);">Haluatko tiedon kun sivusto aukeaa? Anna s&auml;hk&ouml;postisi alle.<br><br></p>
  <form action="#" method="post" style="text-align:center;" id="formi">
        <input type="email" name="sposti">&nbsp;<input type="submit" class="submit" style="width:50px;">
    </form>



    </body>
</html>
  • 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-06T19:38:36+00:00Added an answer on June 6, 2026 at 7:38 pm

    you’re using the selector $("input#sposti"). however, you don’t have an element with the id ‘sposti`; set your element’s id to ‘spotsi’ and you should be fine.

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

Sidebar

Related Questions

I have a form on my site which sends data to some remote site
I have a simple site, which has a form and an inputbox. I want
I have this simple flyer page which uses jquery to reveal a form via
I have a simple feedback form in a Kentico CMS site. There are two
I have created a simple web app/form using google app engine. the site is
I have simple form like this which accepts only two values string action and
I have this simple form which shows a pop up calendar when clicked on
I have a simple HTML form that posts to a PHP page, which will
I have a very simple contact form on my site, Im looking for users
I have a contact form on site which used to work, but since last

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.