Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Customized Error page

Status
Not open for further replies.

potinenip

Programmer
Jul 12, 2000
35
US
Hi All,<br>I want to create a Professional looking customized error page.<br>I mean when ever user submits incomplete form another page should be shown which looks like the original form showing some message(like &quot;Please enter the user name &quot;)below the user name text box.<br>I have tried the CFERROR and CFABORT tags but i was not completely successful on that. <br>Hope somebody can help me do this.&nbsp;&nbsp;<br>Thanks in advance.<br>Praveen
 
You do not need to create an error page, you simply create the form so that it checks for the existance of the form elements first, if they exist then use them as the value of the form elements, otherwise give them no value and put the error text underneath.<br><br>You check for the existance of the formfields like this<br>&lt;cfif isdefined('form.name')&gt;<br>&lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;#form.name#&quot;&gt;<br>&lt;cfelse&gt;<br>&lt;input type=&quot;text&quot; name=&quot;name&quot;&gt;&lt;br&gt;<br>You must enter a name<br>&lt;/cfif&gt;<br><br> <p>Russ Michaels<br><a href=mailto:russ@satachi.com>russ@satachi.com</a><br><a href= Internet Development</a><br>For my personal book recommendations visit <br>
 
Hi Russ,<br>Thanks for ur replies on my questions.<br>Where do i write this piece of code u gave me. Is it in the actual form or the action form? I don't know why i couldn't figure out. I tried the code on both the pages but it wouldn't work.<br>Suggest me.<br>Thanks<br>Praveen
 
Depends how your doing it, are you using one form that submits to itelf, or two separate pages. I will assume two separate pages as using a single dynamic pahe may be over your head.<br><br>page1.cfm submits to page2.cfm which processes the form.<br>n page2 you check if all the form fields exist, if so then rocess them as normal, otherwise display a second copy of the form that is the same as on page1, except it inserts the form values if they exist and puts the message underneath if they don't.<br><br>To check for all form fiel on page2, use a loop like this.<br><br>&lt;cfset valid = &quot;true&quot;&gt;<br>&lt;cfloop index=&quot;field&quot; list&quot;name,address,telephone&quot;&gt;<br>&lt;cfif not isdefined('form.'&field)&gt;<br>&lt;cfset valid=&quot;false&quot;&gt;<br>&lt;/cfloop&gt;<br><br>&lt;cfif valid&gt;<br><br>do your form processing<br><br>&lt;cfelse&gt;<br>show the form again with fields filled in and errors for non existant ones.<br><br><br>&lt;/cfif&gt;<br><br> <p>Russ Michaels<br><a href=mailto:russ@satachi.com>russ@satachi.com</a><br><a href= Internet Development</a><br>For my personal book recommendations visit <br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top