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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:01:41+00:00 2026-06-11T22:01:41+00:00

I need to do a very basic form validation, and my method of choice

  • 0

I need to do a very basic form validation, and my method of choice is jQuery. However, for some reason, the validation function seems not to get fired at all.

After looking at this for several hours I can’t find out what the problem is.

HTML:

<form id="form1" name="form1" method="post" action="process.php">
    <table width="100%" border="0" cellspacing="5" cellpadding="0">
      <tr>
        <td width="160">Meno:</td>
        <td><input type="text" name="meno" id="meno" /></td>
        <td width="160">Priezvisko:</td>
        <td><input type="text" name="priezvisko" id="priezvisko" /></td>
      </tr>
      <tr>
        <td width="160">Názov spolocnosti: <br />
          <span class="register_comment">(nevyplnajte ak nie ste podnikatel)</span></td>
        <td><input type="text" name="spolocnost" id="spolocnost" /></td>
        <td width="160">Krajina:</td>
        <td><select name="krajina" id="krajina">
          <option value="" selected="selected">&nbsp;</option>
          <option value="cz">Ceská republika</option>
          <option value="sk">Slovenská republika</option>
        </select></td>
      </tr>
      <tr>
        <td width="160">Adresa:</td>
        <td><input type="text" name="adresa" id="adresa" /></td>
        <td width="160">Mesto:</td>
        <td><input type="text" name="mesto" id="mesto" /></td>
      </tr>
      <tr>
        <td width="160">Email:<br />
          <span class="register_comment">(na tento email Vám príde potvrdenie)</span></td>
        <td><input type="text" name="email" id="email" /></td>
        <td width="160">Telefonický kontakt:<br />
          <span class="register_comment">(uvádzajte kontakt na mobilný telefón na ktorom budete zastihnutelní najmä 10.10.!)</span></td>
        <td><input type="text" name="telefon" id="telefon" /></td>
      </tr>
      <tr>
        <td width="160">Miesto nástupu: </td>
        <td colspan="3"><select name="nastup" id="nastup">
          <option value="" selected="selected">&nbsp;</option>
          <option value="nr">Nitra</option>
          <option value="ba">Bratislava</option>
          <option value="br">Brno - Avion Shopping Park, Škandinávská 128/2</option>
          <option value="ph">Praha - Avion Shopping Park, Škandinávská 15/A</option>
          <option value="pl">Plzen - OC Olympia, Písecká 972/1</option>
        </select></td>
      </tr>
      <tr>
        <td colspan="4"><p>
          <label>
            <input type="checkbox" name="suhlas" value="checkbox" id="suhlas" />
            Oboznámil som sa s podmienkami úcasti a Súhlasím s podmienkami úcasti  </label>
          FLEX Polishing Camp<br />
        </p></td>
      </tr>
      <tr>
        <td colspan="4" align="center"><input type="submit" id="button" value="Odoslat záväznú prihlášku na FLEX Polishing Camp" style="width:500px;" /></td>
      </tr>
      <tr>
        <td colspan="4" class="register_comment">xxxx</td>
      </tr>
    </table>
</form>

jQuery:

<script>  
    $("#form1").submit(function() {
      var errors = new array();
      if ($('input[name=meno]').val() == "") {
        errors.push('Meno je povinná položka.');
      }
      if ($('input[name=priezvisko]').val() == "") {
        errors.push('Priezvisko je povinná položka.');
      }
      if ($('input[name=krajina]').val() == "") {
        errors.push('Je nutné vybrať si krajinu - ČR alebo SR.');
      }
      if ($('input[name=adresa]').val() == "") {
        errors.push('Adresa je povinná položka.');
      }
      if ($('input[name=mesto]').val() == "") {
        errors.push('Mesto je povinná položka.');
      }
      if ($('input[name=email]').val() == "") {
        errors.push('Email je povinná položka.');
      }
      if ($('input[name=telefon]').val() == "") {
        errors.push('Telefonický kontakt je povinná položka.');
      }
      if ($('input[name=nastup]').val() == "") {
        errors.push('Telefonický kontakt je povinná položka.');
      }
      if (!$('#suhlas').attr('checked')) {
        errors.push('Je potrebné vysloviť súhlas s podmienkami zaškrtnutím tlačítka "Oboznámil som sa s podmienkami účasti a Súhlasím s podmienkami účasti FLEX Polishing Camp".');
      }
      if ( errors.lenght > 0 )
      {
        var text;
        for (var i = 0; i < errors.length; i++) {
            text = text + errors[i] + '\n';
        };
        alert(text);
        return false;
      }
      return true;
    });
</script>  
  • 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-11T22:01:43+00:00Added an answer on June 11, 2026 at 10:01 pm

    As other mention you have missed the # for your ID selector, you can also use map method and minify your code.

    $("#form1").submit(function() {
          var errors = [];
          errors = $('input[type=text]', this).filter(function(){
                return $.trim(this.value) == "";
          }).map(function() {
                return this.name + ' je povinná položka.';
          }).get();
    
          if (errors.length) {
               var text = errors.join('\n');
               alert(text);
               return false;
          }
    });
    

    http://jsfiddle.net/bwVWQ/

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

Sidebar

Related Questions

I have a very basic form, with some very basic validations (though I need
I only need a very basic/simple form to send the email but it doesn't
I need very basic template engine, which is incapsulated in single class. So I
visual basic editor in autocad is very low level , i need a more
I need a very simple jQuery to constantly scroll a list of text items
I need to complete a very simple application. We want to archive some Sharepoint
I need to develop a basic web app very quickly (1 week) for a
I'm storing some very basic information data sources coming into my application. These data
I am very new to Spring and I have been given some basic instructions
I'm trying to use jQuery validation plugin to validate a few form fields by

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.