I have a form, that is populated by a bean, which updates the bean
when the form values are submitted.  The update is done very simply
using cfset my.setMemento(#form#).

My question now is how do I error check and make the error message
something useful to the user.  If a user enters a non numeric value
into a numeric form field that tries to update the bean, an error is
thrown like:
  

A form field is always a string, so your bean should accept only strings. Once bean is updated with the values from the form, then you can validate a particular field however needed.
 The value returned from function getNumberValue() is not of type numeric.

I am using http://rooibos.maestropublishing.com/ to generate the bean
and there is an option for validating.

I also understand that I could create a cfc that would pass the values
to the bean, check for errors and return messages in a more manual
way, but the setMemento is so easy, If I could figure out error
checking also, it would save me alot of time in future projects.
  
I suppose validation will always have some custom elements to it. One of the things i really "hate" when people design validation systems is they don't take the perspective of the user. I happen to live in Europe and i've often run afoul of validation routines in websites, (Adobe's support site was the latest) that were simply unnecessary. The area code in my phone number has 2 digits. But the programmer who designed Adobe's support website assumed that all area codes everywhere must have 3 digits, or it's not a real phone number.

Ironically, i had to submit a fake phone number so it would be "valid".

I've also seen programmers validate a phone number field as numeric, because it's a phone number, but what happens when you have an extension and can't enter it?

I've also seen programmers assume that a phone number is number that has 10 digits, and cannot begin with a 0.

The bottom line here is you can't force a person to give you their real phone number or a real email address with "validation" - that strategy may even backfire. And even in the case of required fields ... my stance here from a usability perspective is to leave it as open as possible. If someone just wants to leave you their email address and a first name and not their phone number, street address, date of birth and mother's maiden name, fine. Let them leave the information they want to leave. In my opinion, a form is much more "usable" if it lets me fill in what i want.

Of course, some business rules will insist that certain fields are required. But then they generally will make sense to the user. You can't have an application to apply for a copy of your birth certificate where first name, last name and mother's maiden name are optional.

If for some reason your program needs the data in a certain type (say you need room numbers numerically sortable - i just ran into that yesterday) - I still wouldn't validate that room number field as numeric! I'd let users enter their valid data, even the ones who have room numbers 2A, 2B, and 3C ... and figure out how to deal with that within the program itself.

There. Now i've saved you a lot of time in your future projects with my simple plea. Validate sparingly! Let me enter my real phone number, billing address, and zip code once in awhile.

;-)

ciao,
Nando
TIA,

--
David Mineer Jr
---------------------
The critical ingredient is getting off your butt and doing
something. It's as simple as that. A lot of people have ideas,
but there are few who decide to do something about them now.
Not tomorrow. Not next week. But today. The true entrepreneur
is a doer.


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]



  


--


Aria Media Sagl
CP 234
6934 Bioggio
Switzerland
www.aria-media.com


Reply via email to