>>I do some server side error checking on the action page. If an error occurs, I display the error to the user and provide a link (simply window.history.back()) for him or her to return to the form to correct data
try some client side validation too
<form action="' method="" onSubmit="return validateForm(this);">
<script>
function validateForm(objForm){
var strErr="";
var objFocus="";
if (!objForm.formElement.valu
strErr+="FormElement is blank!\nThis is a required field.")
if(!objFocus){
objFocus=objForm.formEleme
}
..do all validation
if(strErr){
alert(strErr);
objFocus.focus();
}
return !strErr;
}
}
}
Main Topics
Browse All Topics





by: riffraff5Posted on 2004-04-22 at 05:31:42ID: 10888049
when you submit your form, set each form field into a variable before processing any error checking...
ue="#first name#"</cf if> size="30" maxlength="30">
<cfset firstname=form.firstname>
<cfset lastname=form.lastname>
etc.
On your form page, check for the existance of the variable to populate the field.
<cfinput type="text" name="firstname" <cfif isdefined("firstname")>val
The more proper method is to use cfparam at top of your form page and default each form field to "".
<cfparam name="firstname" default="">
<cfparam name="lastname" default="">
then set each form field as follows:
<cfinput type="text" name="firstname" value="#firstname#" size="30" maxlength="30">
<cfinput type="text" name="lastname" value="#lastname#" size="30" maxlength="30">
if the user submits the form and the variables are set on your action page as described above, the variables will remain constant regardless of the problems they may encounter.
hope this helps