Hello, your function looks syntactically correct, although it makes more sense to use “else if” instead of an “if” inside the “else” block.
What do you expect that code to do and how does it fail? In your browser’s console (F12 → Console) you should see warnings and/or error messages, so check that out while testing.
if (something)
{
statement;
}
else
{
if (somethingelse)
{
statement;
}
}
To use:
if (something)
{
statement;
}
else
if (somethingelse)
{
statement;
}
If that is what you mean then it is just a matter of style. Some developers always use blocks and some do not. If the code will always be worked by one person then that person can do whatever they prefer. If code is to be worked by multiple developers then the standard should be followed, whatever the standard is for the organization or project or whatever. The computer does not care.
I could suggest an alternative but I assume you will keep the suggestion you have already. I however would do as suggested by @igor_g.
Note that I would also do something more after doing the submit; that is, when the text is “Human? Click Again” I might reset things to the beginning or I might disable the text.
This is off-topic from your question but for spam I was receiving much spam from a contact page for a website I have since removed temporarily. What I discovered however is that all the spam was sent with X-Sender-Info: perfora.net in the header. There were very many From email addresses but evidently they were all sent from one server, or something like that. If you want more about that then ask a new question so it can have a topic of its own and you can get help from the most people possible.