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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:05:14+00:00 2026-05-13T14:05:14+00:00

I have a simple javascript function to validate a form (RSform!Pro in Joomla) on

  • 0

I have a simple javascript function to validate a form (RSform!Pro in Joomla) on submit. Problem is bots are able to submit the form without the validate script running when they have javascript disabled. The only option I can think of to prevent this case from happening is to use php instead of javascript. Could someone help me with this conversion or offer an alternative?

    function validateEntreeCount(theForm)
    {
     if (parseInt(document.getElementById('Attendees').value) != 
parseInt(document.getElementById('Beef').value) + 
parseInt(document.getElementById('Chicken').value) + 
parseInt(document.getElementById('Vegetarian').value))
     {
      alert('The total amount of attendees does not match the total amount of entrees selected'); 
      return false;
     } 
     else
     {
      return true; 
     }
    }

Thanks for everybody’s input!

  • 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-13T14:05:14+00:00Added an answer on May 13, 2026 at 2:05 pm

    In order for the conversion to work, I will have to assume a few things, so let me show you a conversion with my general assumptions:

    My assumed HTML page, containing a form with a few input types, total number of attendees, a number indicating how many orders of what type of dinner and a submit button. Notice the method of the form is a post and the action is yourfile.php.

    <form name="my_form" method="post" action="yourfile.php">
       <input type="text" value="Attendees"></input>
       <input type="text" value="Beef"></input>
       <input type="text" value="Chicken"></input>
       <input type="text" value="Vegetarian"></input>
       <input type="submit" value="submit"></input>
    </form>
    

    Your PHP page that will retrieve the form values:

    <?php
      function validateEntreeCount() {
       // used for validation purposes
       if (!isset($_POST['submit']) {
           // form was submitted without data, silly bots.
         echo "We've encountered a problem, please re-enter your data";
          // possible redirect back to the page.
       }       
       // convert the data into integers.
       $total   = intval($_POST["Attendees"]);
       $beef    = intval($_POST["Beef"]);
       $chicken = intval($_POST["Chicken"]);
       $veg     = intval($_POST["Vegetarian"]);
    
        // if all is well, everything should be equal
         if ($total == ($beef + $chicken + $veg)) {
           return true;
        }  
       // something went wrong
           echo "The total amount of attendees does not match the total amount of entrees selected";
           return false;
      }
    ?>
    

    This hasn’t been tested or compiled, just demonstrating how the comparison function would look like in PHP. There are many things to work on, especially validating input and error checking.

    Hope this helps you out, or points you in the right direction.

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

Sidebar

Ask A Question

Stats

  • Questions 291k
  • Answers 291k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think I've managed to find a way that works.… May 13, 2026 at 5:57 pm
  • Editorial Team
    Editorial Team added an answer Free the context, everything else is local to the context… May 13, 2026 at 5:57 pm
  • Editorial Team
    Editorial Team added an answer I find it interesting that your derived forms do not… May 13, 2026 at 5:57 pm

Related Questions

I'm working on a simple javascript login for a site, and have come up
Here a sample use case: I request a simple form via an ajax request.
A very general question. I am dynamically generating a form that is split into
I have a HTML form which uses special characters in ids ( :,-,_ ).
I'm coding an italian website where I need to validate some input data with

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.