Jun 3rd, 2011, 2:28 AM
Hi Asgaroth,
Sorry for not responding to this sooner.
There are really only two methods: client-side (JS with RSV) and server-side (with the PHP version of RSV). Both validation libraries come bundled with Form Tools for your use. Depending on your requirements, you can use one, both or neither.
RSV
Using the Really Simple Validation JS has it's advantages. First, it lets the user know what the problems are right away - right at the moment they submit the form. From a usability perspective, client-side validation is terrific. However, there are drawbacks: maybe the user doesn't have javascript enabled in his/her form, or maybe you're dealing with someone Evil who wants to hack your form by submitting dud values: this is all too easy for hackers, so the security-conscious can't rely on client-side validation.
PHP Validation
This is done on the server and is immutable. Provided your logic is tight, hackers won't be able to get around it. However, from a usability perspective it's kind of crumby: users would submit the form, wait, then the page would reload showing whatever errors were detected by the server.
So most times, I use both methods. That's pretty much the difference!
The third point you raised is actually just syntactic. Javascript and PHP are very different languages and work differently. The rules.push("if:condition,...") syntax of RSV was written to allow for conditional logic to be applied to your validation rules, but on the server, you don't need anything so fussy (though if memory serves, it still supports that syntax...).
Anyway, hope this info helps!
- Ben
Sorry for not responding to this sooner.
There are really only two methods: client-side (JS with RSV) and server-side (with the PHP version of RSV). Both validation libraries come bundled with Form Tools for your use. Depending on your requirements, you can use one, both or neither.
RSV
Using the Really Simple Validation JS has it's advantages. First, it lets the user know what the problems are right away - right at the moment they submit the form. From a usability perspective, client-side validation is terrific. However, there are drawbacks: maybe the user doesn't have javascript enabled in his/her form, or maybe you're dealing with someone Evil who wants to hack your form by submitting dud values: this is all too easy for hackers, so the security-conscious can't rely on client-side validation.
PHP Validation
This is done on the server and is immutable. Provided your logic is tight, hackers won't be able to get around it. However, from a usability perspective it's kind of crumby: users would submit the form, wait, then the page would reload showing whatever errors were detected by the server.
So most times, I use both methods. That's pretty much the difference!
The third point you raised is actually just syntactic. Javascript and PHP are very different languages and work differently. The rules.push("if:condition,...") syntax of RSV was written to allow for conditional logic to be applied to your validation rules, but on the server, you don't need anything so fussy (though if memory serves, it still supports that syntax...).
Anyway, hope this info helps!
- Ben