View Full Version : adding a validated field
jspoerer286380
02-21-2010, 03:49 PM
Hi everybody... I just bought the Contact Form Solution Pack and Iīm dissapointed !!
The first thing I wanted to do is to add a new field to the form but validated the same way they are in the original form and it seems is not possible if you donīt have the CSS Form builder !! I donīt remember that they warned the clients with this issue... If I knew this before i wouldnīt buy the Solution Pack.
Does anybody now if it is possible to add a validated field without having to buy another product ???
Thank You in advance,
Jorge Spoerer
CHILE
Dani Chankhour
02-22-2010, 12:37 PM
Yes. You could add spry validation to your new field. In Dreamweaver open the Insert Menu (Window -> Insert), click on the text field, and then select spry from the insert menu, and select Spry Validation Text field.
Note: Although this is not a common case, but this is a client side validation, so if the user have Javascript disabled on their browsers then the validation won't work.
Let me know if you have any other questions.
jspoerer286380
02-22-2010, 01:29 PM
Thanks for your help Dani.... but I did exactly that !! (before sending my post). That gave me some client validation you are right...
But I was meaning server side validation as well... as the other fields of the form... is that possible ??
BR,
Jorge
Dani Chankhour
02-23-2010, 07:22 PM
Yes. This will require a few steps.
1. First you need to make a copy of a line 14, which is a validation for the name field and past it under line 20. And then you will need to update two things: the form element name, and the last parameter value from 1 to 7.
2. Then start by copying line 68 to 77 and pasting that under the form field you have added. Again make sure to replace the name with your form field name. If you have already applied spry validation, then you probably just need to surround the spry with line 68-72 and line 74-77.
Basically, if you use one of the already existed form elements as a starting point, and just change the form element name in the validation and add the extra line of code at the top of the page, you should be able to add server side validation to your new form element.
jspoerer286380
02-24-2010, 07:50 AM
Thank You Dani... I will try it...
One doubt... what are those 2 input fields called "addblock" & "secondblock" the form has ??
BR,
Jorge
Ray Borduin
02-24-2010, 07:58 AM
Those are honeypot fields. They are placed there to try to fool bots into filling them out to prevent non-human browsers from validating.
Honeypot fields are invisible fields on the form. Invisible is different than hidden. Hidden is a type of field that is not displayed for editing. Bots understand hidden fields, because hidden fields often carry identifying information that has to be returned intact. Invisible fields are ordinary editable fields that have been made invisible in the browser.
The invisibility of the honeypot fields is a key way that bots reveal themselves. Because bots do not process the entirety of the HTML, CSS, and Javascript in the form, and because they do not build a visual representation of the page, and because they do not perceive the form as people do, they cannot distinguish invisible fields from visible ones. They will put data into honeypot fields because they don't know any better.
jspoerer286380
02-24-2010, 08:07 AM
Hi Dani... itīs me again
The form is not working for me... I donīt know if I can ask you to send me a copy of the contactus.php file but with 2 additional validated fields. One the same as the "Contact_Name" and other validating numbers since i would like to use it for a phone number...
Thatīs all I need please,
Thank You,
Jorge
Dani Chankhour
02-24-2010, 02:35 PM
I can't really assist you with that, but if you send me your contact page (only the contact page), i will try to debug the issue on my end and tell you what you need to change exactly.
jspoerer286380
02-25-2010, 07:25 AM
Ok Dani, here goes the file... Is the original contactus.php of the contact form package without one security question but with 2 new fields.. one for the family name and other for a telephone number.
BR,
Jorge
Dani Chankhour
02-26-2010, 11:49 AM
Ok, so you will just need to add these two lines of code under line 19 of your page:
$WAFV_Errors .= WAValidateRQ(((isset($_POST["apellido"]))?$_POST["apellido"]:"") . "",true,8);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["telefono"]))?$_POST["telefono"]:"") . "",true,9);
And then on line 87 change the "1" to an "8" and on line 103 change the "1" to a "9".
this will give you fields server side validation, you will just need to update the text that is shown for the validation.
jspoerer286380
02-26-2010, 04:54 PM
Hi Dani, thank you for your help... I did what you told me but there is still a problem...
First, when you test the page in Fireworks, it displays the server validation messages even that you have not pressed the submit button... (see fig. web1)
Then, when you fill in the fields... in the original field ones the server validation message goes but in the new ones (the fields I add to the form) the message donīt go (see fig. web2)
Can you help me with this strange behaviour ??
Best,
Jorge
neilo
02-26-2010, 07:23 PM
<input type="text" class="inputValue" name="telefono" id="telefono" onblur="if (document.getElementById('nameServerError')) document.getElementById('nameServerError').style.d isplay='none'" value="<?php echo(ValidatedField("contact","apellido")) ?>" />
Should that be 'telefono'?
Hi Dani,
Do the ServerError references not need to be unique to each field - i.e:
document.getElementById('apellidoServerError')
and:
<span id="apellidoServerError" class="textfieldServerError">Please provide your family name.</span>
document.getElementById('telefonoServerError')
and:
<span id="telefonoServerError" class="textfieldServerError">Please provide your telephone number.</span>
blackweldermhe400113
03-11-2010, 09:08 PM
Alright, I am attempting to make several additions to the contact form solution. The additions will include a select menu, radio buttons, and new input fields. I have already added another form field, and it appeared to be validating ie. when you selected the field and then tabbed through to the next form field without inserting a value the field would give you the "A value is required" message in error state. The problem I'm having is when you submit the form with that field in an empty state it returns the second error message and I can't get rid of it once the field has a value applied to it. I'm attaching my file for you to look at. My next question is how you would validate a select menu within a form with the same server side validation?
Dani Chankhour
03-15-2010, 01:56 PM
neilo, you are correct, the spry id needs to be unique on all the fields.
blackweldermhe400113:
for the company name, you should change this line of code:
<span id="nameServerError" class="textfieldServerError">Please provide your company name.</span>
to
<span id="companyServerError" class="textfieldServerError">Please provide your company name.</span>
and then change this line of code:
<input name="Company_Name" type="text" class="inputValue" id="Company_Name" onblur="if (document.getElementById('nameServerError')) document.getElementById('nameServerError').style.d isplay='none'" value="<?php echo(ValidatedField("contact","Company_Name")) ?>" />
to
<input name="Company_Name" type="text" class="inputValue" id="Company_Name" onblur="if (document.getElementById('companyServerError')) document.getElementById('companyServerError').styl e.display='none'" value="<?php echo(ValidatedField("contact","Company_Name")) ?>" />
in regard to adding server side validation you should be able to follow the same steps as you did for the company name field.
Let me know if you still have any other questions.
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.