|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
||||
|
||||
|
Don't clear my page when I go back!!
I have a page that a user inputs data into. They click next and the data is error checked. If a problem is found it posts a message like, "The VARIABLE must be a number." or "The VARIABLE must be X long." Then at the end of list of errors it says, "Please click your browser's back button to correct this."
My issue is when they click back the form is reset and they have to enter everything again. (like if you hit the reset button) I could have sworn that this never happened before... Is there a limit to the number of form fields it will cache before it gives up? I have move than 50 of them. I am "Form Method=Post"-ing the data to the next page. Thanks for the help!
__________________
Forget Milk! Gotspy? www.gotspy.com |
|
#2
|
|||
|
|||
|
I don't recommend using the built-in CF server side validation. Do it yourself and then you can handle the errors however you like, maybe redisplay the form with the errored fields highlighted or something...
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
||||
|
||||
|
Kiteless,
Thanks for the reply! The validation that I am doing, I am writing in all on my own. Here's more on how it works: Form name=test action=submit.cfm input type=text name=phone size=10 maxlength=10 input type=text name=name size=30 maxlength=30 /form On the submit page: cfif isnumeric(phone) IS "no" display: Dude, use numbers, DUH! /cfif cfif len(name) IS 0 display: is this the artist formerly known as prince or something? Enter a name! /cfif That is SUPER simplified, but that is the jist of it. I use it on all of my forms and is very flexible, and allows me to make sure I am getting just the data I want. It also a lot faster to code than to redisplay the page with the errors bold and red. Know what I mean? So the user gets an error page telling them what they goofed up, and tells them to go back and fix it, but with this one, when they go back, they get a reset form and have to start over... ![]() |
|
#4
|
|||
|
|||
|
I think this is a browser issue or an HTTP header issue. Basically this isn't a CF problem.
One option might be to use session variables, set them to default to blank on your form when the user first fills it out, and then set them on your validation page to the values used in the form. When they go back, you'll be populating the fields with the values from the session variables. And, while it might be easier for *you*, I'm sure it is *not* easier for your users to have to go back and remember what your validation messages were. What if there were 15 failed messages? Yes it's more work, but that's our job. I'd still recommend that you redisplay the form and highlight the problem fields. Or better yet, avoid a lot of the problem by using some Javascript. You still need to validate on the server side too in case Javascript is turned off, but you'll catch 95% of these before the user even submits the form. Check out the qForms API from Pengoworks. |
|
#5
|
||||
|
||||
|
Bah! I'm leaning towards what you are saying, it being an HTTP or browser issue.
![]() I know what you mean about redisplaying the form, if it wasn't a fast and dirty form for our sales force, I would redisplay the form, but they never listen and this will be a pain for them, so all the better for my laughs as I watch them try to cut corners, then have to go back... MuHaHaHa... Althought filling out the form again is a bit rough... ![]() I'm going to look more into your session var idea. That sounds good. ![]() Thanks! |
|
#6
|
||||
|
||||
|
Sessions is the key!
1. First put this on top of page Code:
<CFIF (NOT IsDefined("SESSION.Alas"))>
<CFSET SESSION.Alas= StructNew()>
<CFSET SESSION.Alas.FirstName = "#CFQUERYNAMETHATYOUPUT.FirstName#">
</CFIF>
2. Then put this Code:
<CFIF IsDefined("Form.FirstName")>
<CFSET SESSION.Alas.FirstName = Form.FirstName>
</CFIF>
This will get you started, you should then create a sort of wizard that will go from a form page to a Thank You "PERSONS Name" Good hunting -Alas |
|
#7
|
|||
|
|||
|
Even easier:
At top of form page... <cfparam name="session.alas" default="#structNew()#" /> <cfparam name="session.alas.firstName" default="" /> In the form... <input type="text" name="firstName" value="#session.alas.firstName#"> So it would be blank by default, but on the validation page you can then do... <cfif validationFailed> <cfset session.alas.firstName = form.firstName> <cfinclude template="dsp_theform.cfm" /> or maybe a cflocation... |
|
#8
|
|||
|
|||
|
If you are running CFMX, AFAIK you do not have to use the first line. It will create a structure for you if doesn't exists
<cfparam name="session.alas" default="#structNew()#" /> <!--- you do not need this ----> <cfparam name="session.alas.firstName" default="" /> |
|
#9
|
|||
|
|||
|
True, the first line isn't required. But I think that explicitly declaring it makes your intentions more clear.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Don't clear my page when I go back!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|