Form validation using simple jQuery

I like to set a basic form validation protection in a simple way.

//Are you a bot?
  //<input type="hidden" name="qsum-response" value="4" />
  //<input type="hidden" name="qsum" value="10-6" />

How to add form validation as a dynamic qsum value using Javascript and replace INPUT fields which are actually HTML insertations?

I recommend that you just process those qsum fields on the server side.

reads topic title
“using simple jQuery”… k…

…a wha…

I dont know what is generating these 'qsum’s, but… the basic answer from me is going to be “Regex the hell out of it.”

Pull all of the operands: Regex Match All \d+ (if it can use floats then we’re in another world.
Pull all of the operators: Regex Match All [+-*/]
Integerize all the operands
Handle multiplication and division
Handle addition and subtraction.
Integerize the response.
If response = total, yay.
(Note that this method is true regardless of if doing it at Client or Server side. You should really probably be doing it at both.)

Is there an example for PHP although I know this topis was meant for Javascript?

Actually, in PHP my head is doing it easier.

Regex to validate the string - assert that the string is comprised entirely of digits, +, -, *, /
Eval the string.
Compare the eval to the submitted value.
That said, it does seem a rather easy system to bypass.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.