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!
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.Your PHP page that will retrieve the form values:
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.