Client side validation
Thu, 11/26/2009 - 00:35
Can someone point me to a tutorial or other guidance on how to do client side validation. For example, I have a textbox, where only "Y" or "N" values are valid. This is pretty simple validation, so I would like to perform it on the client side, when the cursor leaves the field. I'm sure it must be possible, but haven't been able to find any information on how to do it.
Thanks.

I don't know if this is easily doable through client-side, but I know that you can do this through a QAjaxAction triggered on a textbox changed event - this way, to the user, it will appear as it's all happening client-side.
The easiest way is to use something like jQuery's Formatted Textbox plugin, which forces user input of textboxes to match some predefined format.
If I used a concept similar to the Examples Site's AJAX Calculator, would the validation be done client side, or would it cause server side activity. I was thinking of performing validation on blur from the affected field. However, I have no idea what or even if there's an on blur option for QAjaxAction. In the mean time, I'll look into the JQuery Formatted Textbox. I'm a real novice and still don't really know what I don't know at this time.
Thanks.
Basically QCubed has no built-in support for client side validation.
If you want client side validation, you will have to use javascript to accomplish it. There are many jQuery and other javascript client side validation tools out there to help with this, and if you make a QCubed plugin to make using them easier, the community would love the effort. :)
Also note that any client side validation you do have can easily be bypassed, so you should _always_ do server side validation.
Yeah, I personally think that client-side validation is the devel. It's better the do server-side validation and optimise your application for fast Ajax responses than the cave in and go for client-side validation.
Particularly horrifying are those case where there is no server-side validation.
That is the stuff SQL Injection attacks are made of.
I'm actually a big fan of client side validation (backed up by server side as well). It works 95% of the time, and reduces server load. Less server load means better performance where it's needed.
It also makes for a much snappier and responsive experience for the user, and if done right can be much more obvious and user friendly than having them have to re-read the entire page to see where an error occured.
Vexed, although I didn't mention it, the plan is to validate on both client and server sides. The idea was to give the user a quick response to data entered in the field, but, when the form is submitted to the server, all validation would be performed again. This should mostly prevent malicious injection and yet improve the users experience. I guess we're all looking for instant satisfaction these days.
Anyway, I appreciate the input from you both. I'll see what I can do and if I end up creating a plugin, I'll make it available to all.
Thanks, again.