View Full Version : form fields not validating properly
Brendafrank306873
02-19-2010, 10:01 AM
Using the Contact Form solution Pack and Dreamweaver, I made a form here: http://loggialaw.com/testLoggia/forms/ContactForm_GMC/contactus.php The email notification works. The security works. Some of the required fields, like name, work. However, when you submit without the name, the form highlights ALL of the fields with error messages.
If you omit some of the other required fields, like phone number (day) or the checkboxes, the form submits and sends the email.
I don't know PHP. I have read all the supporting materials and the relevant forum messages and I need help making this behave properly. I have attached the php page. Thank you.
neilo
02-19-2010, 11:40 AM
Hi Brenda,
You have added
<input name="addblock" type="text" id="addblock" style="display:none" value="" >
to each of your input fields, and each one has the same ID. There would need to be a seperate 'WA Sever Validation' server behavior for each field, in the php code that is placed before the DOCTYPE declaration, with a separate ID to correspond with each of those lines.
I think you could just remove these lines from all but the 'name' input field and let the spry validation widgets take care of the rest.
Brendafrank306873
02-19-2010, 07:03 PM
Hi Neilo,
I did as you suggested and deleted the <input name="addblock" type="text" id="addblock" style="display:none" value="" >
from all but the name fields. The form validation is still wacky. No change.
If I fail to fill in the name, the form displays ALL the error messages.
If I leave out other required fields like address, the form submits and thanks me. Same with failure to check any boxes.
If I fail to fill in the comment area, the form behaves correctly by telling me to fill out the comment area, but NOT displaying the error messages in the other fields.
Still need to figure this out.
neilo
02-19-2010, 11:15 PM
Hi Brenda,
That's odd. Is it OK to do test 'sends' using the form, or does it go to someone who wouldn't appreciate getting test emails?
neilo
02-20-2010, 12:40 AM
Hi Brenda,
For many of the fields you have the same onBlur server error ID (nameServerError), so they will all display similarly if the 'name' field doesn't validate.
I think the best bet would be to keep the original contactus.php fields and sections of code (both above the 'DOCTYPE' line and in the javascript widgets at the end) and clear the rest of the fields of any spry or error code - so it is just the input (type name id etc) left.
Make sure the form sends OK with just the name, email and comment fields requiring validation, then add the validations to your extra fields, either using the Server Validations from the WA Validation Toolkit (Server Behaviors > Click the 'Plus' Button > WA Validation Toolkit > Server Validations), or using the Dreamweaver Insert > Spry > Spry Validation X field.
Doing it this way will ensure that each field will be correctly identified for validationn.
Brendafrank306873
02-20-2010, 05:00 AM
Hi Neilo,
Thanks for the help. Still having the validation problems. I have attached the revised file. I removed the php validation code from the optional fields: address2, eve phone, company and title. The required fields that I added still aren't acting as required fields: the checkboxes, the daytime phone, etc. I still have the validation message problems.
It's ok to test the form. The email comes to me. I've done it dozens of times. I think that I just don't understand the php and spry code enough to do this. I used the Contact Form program and Dreamweaver.
The form does submit, with the thank you page and the email is sent, the validation on the fields is the only problem.
Not there, yet.
neilo
02-20-2010, 02:13 PM
Cheers for uploading the page. I will go over it tomorrow am and post back.
neilo
02-21-2010, 04:17 AM
Hi Brenda, - have been going over your page (using it as a learning tool) and think it's pretty much there now. Have been testing it here and haven't found any holes, but I now have form-code blindness and may have missed a testing permutation.
Could you give it a thorough testing please and post back if you find any problems?
I have zipped and attached the revised page.
Update: Fixed the 'Show If' server behaviour for multiple checkboxes.
Brendafrank306873
02-21-2010, 06:47 AM
Hey Neilo,
You're my hero! Actually, I added a spry widget to the e-mail field so that it behaved like all the other required fields. The 3-checkbox group was supposed to be a required check one but wasn't. But, I really don't think that matters (unless the client says it does).
Now, it's behaving perfectly, just like it's supposed to. Thank you so much for your help.
Brenda
neilo
02-21-2010, 06:52 AM
Brilliant - glad you got it sorted.
I didn't know whether the 3 checkbox validation was for one, two or all, so I just set it to 'at least' 1.
Cheers
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.