Oguz.Demirkapi wrote:
> You need to validate your form fields either in server
side via CF or in client
> side via JavaScript etc.
it is not either / or. you should ALWAYS validate form data
on the
server. you can also use client-side validation to make it
more
user-friendly, but never rely on it to validate your data.
validate on
the server. for one, if a client has js turned off in their
browser your
client-side validation flies out the window...
i have not checked the links Oguz provided, but basic concept
of form
validation is:
<cfparam> your form vars on the action page to default
values - that way
if a user does not fill in a field, it will default to the
value you set
in cfparam for it.
text fields ALWAYS have a value - an empty string '' if it
has not been
filled in. checkboxes and radio button, if not checked, are
not
submitted with the form. so cfparam those always.
drop-down select lists are treated differently by different
browsers.
some preselect the first element in the list, others set the
value of
the select to -1 if nothing is selected. you can control
default
selection in the list with seslected="selected" attribute in
the field.
it is useful to cfparam these as well...
if you want the user to be able to try submitting the form,
show errors
on next page, then return to the form and have their
previously entered
data pre-filled for them, use session-scope vars to store
form data:
just copy your form to session var on your action page. make
sure
sessions are enabled in cf administrator and in your
application.cfm/cfc
hth
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/