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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remember what was on a form

Status
Not open for further replies.

sborny

Technical User
Jun 29, 2001
157
GB
Hi,

I am putting together an application form on a site that needs to have certain fields set as mandatory.

I can get the form to check if the fields are empty and re-direct to an error page but when you go back to the form, all the data that was entered is no longer there.

Does anyone know how to do this. I am afraid that I don't know Javascript or PHP or anything like that so a sample form would be great that I can download and play with to see how it works.

Thanks

S.

Everything has an answer, it's just knowing the right question to ask. !!!!
 
If you are "...check(ing) if the fields are empty..." and redirecting the user to an error page, why not do the same validation using Client-Side JavaScript.

That way you won't need to store the values - they will be verified before the form is submitted. Use an "onsubmit" of the form to call a verification function. There should be plenty of posts on validation. Try:
thread216-745850
... this has a working example listed near the end.

Pete.


Lotus Notes Web Developer / Aptrix (LWWCM) Consultant
w: e: Pete.Raleigh(at)lclimited.co.uk
 
Hi WartookMan,

Thanks for that. I have used the code and pasted my form into it. It seems to work fine except the field names are being displyed properly when the error message appears.

I don't really want to post the code here as it is quite long as the form is quite big.

I can e-mail you the file if you like. I am sure it has something to do with the fact that my form is formatted using tables.

Any ideas

Thanks

S.

Everything has an answer, it's just knowing the right question to ask. !!!!
 
sborny,

To remember all of the selections that were made on the form before, you need to add persistence the the form. Check the following documentation.


As Pete stated, you should also have client side script to verify that all required data is already present before the user can submit.
 
Please email the code to: buk_nayked(at)yahoo.co.uk if you'd like me to have a look.

Pete.


Lotus Notes Web Developer / Aptrix (LWWCM) Consultant
w: e: Pete.Raleigh(at)lclimited.co.uk
 
WartookMan,

Cheers for that. I am not at my machine at the moment. I will e-mail it to you when I get back.

Cheers
again.

S.

Everything has an answer, it's just knowing the right question to ask. !!!!
 
Hi,

I have just e-mailed the htm file to you and got an error message saying that the e-mail does not exist.

I will post a cut down version of the code.

Cheers

S.

Everything has an answer, it's just knowing the right question to ask. !!!!
 
Okay,

Here is a cut down version.


<html>
<head>
<SCRIPT language=&quot;JavaScript&quot;>
<!--
function VerifyFields() {
var msg=&quot;The following fields must be filled in:&quot;;
var blank=false;
for(var x=0;x<document.forms[0].length;x++) {
theObj=document.forms[0].elements[x];
theType=theObj.type;
theName=theObj.name;
theValue=theObj.value;
if((theType!=&quot;SUBMIT&quot;)&&(theType!=&quot;RESET&quot;)) {
// an input field requiring validation - ignore txtAddress2
if((theName!=&quot;txtAddress2&quot;)&&(theValue==&quot;&quot;)) {
msg+=&quot;\n* &quot;+theName.substring(3,theName.length);
blank=true;
}
}
}
if(blank) {
alert(msg);
return false;
}
return true;
}
function VerifyData() {
if (VerifyFields()) {
if (document.frmUser.txtPassword.value != document.frmUser.txtVerifyPassword.value) {
alert (&quot;Your passwords do not match - please reenter&quot;);
return false;
} else return true;
} else return false;
}
//-->
</SCRIPT>
<title>Application Form</title>
</head>
<body style=&quot;font-family: arial&quot;>
<div id=&quot;content&quot;>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;100%&quot; id=&quot;AutoNumber1&quot;>
<tr>
<td width=&quot;100%&quot;>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;100%&quot; id=&quot;AutoNumber2&quot; height=&quot;41&quot;>
<tr>
<td width=&quot;126%&quot; height=&quot;15&quot; colspan=&quot;3&quot;>
</td>
<td width=&quot;2%&quot; height=&quot;3&quot;></td>
<td width=&quot;6%&quot; height=&quot;3&quot;></td>
<td width=&quot;9%&quot; height=&quot;3&quot;></td>
<td width=&quot;20%&quot; height=&quot;3&quot;></td>
</tr>
<tr>
<td width=&quot;3%&quot; height=&quot;3&quot;>
</td>
<td width=&quot;123%&quot; height=&quot;3&quot; colspan=&quot;2&quot;>
<font face=&quot;Arial&quot;><b>Tenant Loan Application Form</b></font></td>
<td width=&quot;2%&quot; height=&quot;3&quot;></td>
<td width=&quot;6%&quot; height=&quot;3&quot;></td>
<td width=&quot;9%&quot; height=&quot;3&quot;></td>
<td width=&quot;20%&quot; height=&quot;3&quot;></td>
</tr>
<tr>
<td width=&quot;1%&quot; height=&quot;19&quot; valign=&quot;top&quot;>
&nbsp;</td>
<td width=&quot;96%&quot; height=&quot;19&quot; valign=&quot;top&quot;>
<form action=&quot;cgi-local/FormMail.pl&quot; name=&quot;Application Form&quot; method = &quot;post&quot; onSubmit=&quot;return VerifyData();&quot;>
<input type=hidden name=&quot;recipient&quot; value=application@southernloanfinda.co.uk>
<input type=hidden name=&quot;redirect&quot; value=&quot; target=&quot;content&quot;>
<input type=hidden name=&quot;subject&quot; value=&quot;Website Tenant Loan Application&quot;>
</font>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;100%&quot; id=&quot;AutoNumber3&quot; height=&quot;1149&quot;>
<tr>
<td width=&quot;39%&quot; colspan=&quot;2&quot; height=&quot;19&quot;>&nbsp;</td>
<td width=&quot;61%&quot; colspan=&quot;2&quot; height=&quot;19&quot;>&nbsp;</td>
</tr>
<tr>
<td width=&quot;100%&quot; colspan=&quot;4&quot; height=&quot;2&quot;>
<img border=&quot;0&quot; src=&quot;images/div.gif&quot; width=&quot;100%&quot; height=&quot;2&quot;></td>
</tr>
<tr>
<td width=&quot;39%&quot; colspan=&quot;2&quot; height=&quot;19&quot;><b><font face=&quot;Arial&quot; size=&quot;2&quot;>Loan Details</font></b></td>
<td width=&quot;21%&quot; height=&quot;19&quot;>&nbsp;</td>
<td width=&quot;40%&quot; height=&quot;19&quot;>&nbsp;</td>
</tr>
<tr>
<td width=&quot;16%&quot; height=&quot;19&quot;>&nbsp;</td>
<td width=&quot;23%&quot; height=&quot;19&quot;>&nbsp;</td>
<td width=&quot;21%&quot; height=&quot;19&quot;>&nbsp;</td>
<td width=&quot;40%&quot; height=&quot;19&quot;>&nbsp;</td>
</tr>
<tr>
<td width=&quot;16%&quot; height=&quot;22&quot;><font face=&quot;Arial&quot; size=&quot;2&quot;>Loan Amount:</font></td>
<td width=&quot;23%&quot; height=&quot;22&quot;>
<select size=&quot;1&quot; name=&quot;Loan_Amount&quot; style=&quot;font-family: Arial; font-size: 10pt&quot; tabindex=&quot;1&quot;>
<option selected>Please Select</option>
<option>£500</option>
<option>£1,000</option>
<option>£1,500</option>
<option>£2,000</option>
<option>£2,500</option>
<option>£3,000</option>
</select></td>


the rest of the form goes here followed by.


<INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Submit&quot;> <INPUT TYPE=&quot;RESET&quot; VALUE=&quot;Clear&quot;>
</form>
<p>
</div>
</body>
</html>



When you press submit without putting in a value for the loan it says that the field &quot;n_Amount&quot; should be filled and does not show the full field name.

Please help.

Cheers S.




Everything has an answer, it's just knowing the right question to ask. !!!!
 

It won't show the full field name - you're explicitly chopping it off!

Change:

Code:
msg+=&quot;\n* &quot;+theName.substring(3,theName.length);

To:

Code:
msg+=&quot;\n* &quot;+theName;

And that should solve that one.

Hope this helps!

Dan
 
Thanks for your help on that. As I siad earlier, I do not knw Javascript at all so I did not know what I was looking for.

One other thing is that the fields that have drop down selection are still showing as needing to be filled even though that have something in them.

Also Do you know how i can test if one filed has an entry in it then it does not need an entry in a specific other field.

ie. If there is a home Phone number entered then I do not need the mobile or daytime phone numbers.

Thanks in advance.

S.


Everything has an answer, it's just knowing the right question to ask. !!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top