Forums

Stiky form

Bouwdewijn 29 Jun, 2007
Hi,
First of all, I like your program installed it and worked immediately. I made a submit form and can receive the e-mail, both sender and admin. The question now is, when a user put something wrong, the form comes back with the error message( e.i. wrong e-mail) then the form is empty when he returns, all correct input is gone and he has to start over again putting in the correct values. I know there is something like sticky form, where the form remembers earlier imputed data. Is ther a way to include this ?

:unsure: I know a little bit about php, but I am not a pro.
Somebody has an idea
Max_admin 29 Jun, 2007
what do you use to check fields ? PHP or javascript ? I suggest js to you dont run into this issue

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 29 Jun, 2007
Hi Bouwdewijn,

As Max says one way to do it is with JavaScript - then the form is not submitted until everything is validated.

I've also been able to make it work with a little hack of the code if your form is simple.

If you set your form to use
. . . name='field_name' value='$_POST[field_name]' . . .
then that will keep the values submitted. You will need to write your validation code in php (see the check security code in ChronoForms for an example) and if you find an error call showform();*

If this sounds too technical then best find Google for some ready-made JavaScript validation code.

Bob

* Actually I changed the code to call showform($error); and post an error message along with the form
Bouwdewijn 29 Jun, 2007
Thanks for your quick response.
I will try both suggestions. And let you know.

Kind regards

Lodewijk
Bouwdewijn 30 Jun, 2007
Hi everybody,

Tried your sugestion and have a validation php script working. Now I also tried a js script. First tried it outsite your component on a blank html page and that worked.

Then I made a new form, past the sample html code in it and also the java script Without the tags as you described.
But I cannot get it to work, it does nothing. I attached the sample scrip. Simple script to validate first and second name. [file name=javascript_form.zip size=8253]http://www.chronoengine.com/components/com_fireboard/uploaded/files/javascript_form.zip[/file]
Max_admin 30 Jun, 2007
Please take care that ChronoForms will change your from name from "myform" to "ChronoContact_myform", I think thats what makes the trouble for you

Cheers

max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Bouwdewijn 30 Jun, 2007
Hi Max,

I will try that.

Have a Nice Weeekend

Bouedewijn
Bouwdewijn 30 Jun, 2007
Hi Max,

Thanks for your help. I got it working now. I will buy a licence.

Kind regards

Bouwdewijn
Max_admin 01 Jul, 2007
Thank you🙂

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
suckerhead 02 Jul, 2007

Hi everybody,

Tried your sugestion and have a validation php script working. Now I also tried a js script. First tried it outsite your component on a blank html page and that worked.

Then I made a new form, past the sample html code in it and also the java script Without the tags as you described.
But I cannot get it to work, it does nothing. I attached the sample scrip. Simple script to validate first and second name. [file name=javascript_form.zip size=8253]http://www.chronoengine.com/components/com_fireboard/uploaded/files/javascript_form.zip[/file]



Hi Bouwdewijn,

Can you direct me the detail, where to put the form code (html), and where to put the js file?

thanks
GreyHead 02 Jul, 2007
Hi suckerhead,

There's a help file 'Documentation.html' in the package that Bouwdewijn attached. Read that with these notes.

1. Include the gen_validator code in your Joomla html header - - look in your template files for a place to add this code
 <script language="JavaScript" src="gen_validatorv2.js" type="text/javascript"></script>"


2. Put the html in the ChronoForms 'Form html' box as usual
 <table cellspacing="2" cellpadding="2" border="0">
<tr>
  <td align="right">First Name</td>
  <td><input type="text" name="FirstName"></td>
</tr>
<tr>
  <td align="right">Last Name</td>
  <td><input type="text" name="LastName"></td>
</tr>
<tr>
  <td align="right">EMail</td>
  <td><input type="text" name="Email"></td>
</tr>
<tr>
  <td align="right">Phone</td>
  <td><input type="text" name="Phone"></td>
</tr>
<tr>
  <td align="right">Address</td>
  <td><textarea cols="20" rows="5" name="Address"></textarea></td>
</tr>
<tr>
  <td align="right">Country</td>
  <td>
  <SELECT name="Country">
<option value="" selected>[choose yours]
<option value="008">Albania
<option value="012">Algeria
<option value="016">American Samoa
<option value="020">Andorra
<option value="024">Angola
<option value="660">Anguilla
<option value="010">Antarctica
<option value="028">Antigua And Barbuda
<option value="032">Argentina
<option value="051">Armenia
<option value="533">Aruba
 </SELECT>
</td>
</tr>
<tr>
  <td align="right"></td>
  <td><input type="submit" value="Submit"></td>
</tr>
</table>


3. Put the validation JavaScript (without the script tags) into the ChronoForms 'Form JavaScript' box. But remember to change the from name to add ChronoContact_
  var frmvalidator = new Validator("ChronoContact_myform"«»);
 frmvalidator.addValidation("FirstName","req","Please enter your First Name"«»);
 frmvalidator.addValidation("FirstName","maxlen=20",
"Max length for FirstName is 20"«»);
 frmvalidator.addValidation("FirstName","alpha"«»);
 
 frmvalidator.addValidation("LastName","req"«»);
 frmvalidator.addValidation("LastName","maxlen=20"«»);
 
 frmvalidator.addValidation("Email","maxlen=50"«»);
 frmvalidator.addValidation("Email","req"«»);
 frmvalidator.addValidation("Email","email"«»);
 
 frmvalidator.addValidation("Phone","maxlen=50"«»);
 frmvalidator.addValidation("Phone","numeric"«»);
 
 frmvalidator.addValidation("Address","maxlen=50"«»);
 frmvalidator.addValidation("Country","dontselect=0"«»);


Bob
suckerhead 02 Jul, 2007
OK... OK...
thanks a lot Bob...
This topic is locked and no more replies can be posted.