Jump to content

Form Validation Script - required attribute for lists


Recommended Posts

Disclaimer: This is my first attempt at doing anything with php, which might be overkill for what's required. Many of the pages of our website have one or more products with multiple selections (drop-down lists). Quite a few orders come in without a selection for one of the critical choices, which necessitates contacting the customer and waiting for a reply. A script which validates required fields could make things run much more smoothly for everyone.


I've downloaded such a script and attempted to validate just one list (outside color) but have been unable to get the validation to work. Any guidance will be much appreciated. The files in question are attached for convenience.





Link to comment
Share on other sites

Am I asking too much? My intention is not to take advantage of anyone's expertise but to gain enough understanding to continue experimenting with the script.


The call to the php script is before the form that asks for all the selections and eventually sends the product to the shopping cart. Toward the beginning of the script is this code:

//Setup Validations
    $validator = new FormValidator();
    $validator->addValidation("outside-color","req","Please select outside color");

At the point where the customer is asked to make a selection for outside color is this:

<select size="1" name="product1[outside-color]">
<option value="dontselect=select outside color">select outside color:</option>
<option value="outside color-White">White</option>
<option value="outside color-Ivory">Ivory</option>

The product is sent to the cart without validating. Where have I gone astray?


Thanks in advance!

Link to comment
Share on other sites

a bit off topic , but shouldn't one should first validate the form thorough javascript or using something like jquery first ??? Giving useless load to the server isn't required , I was in html , css, and javascript  designing before and now moving to php too. In most of the cases there should be validation on both in server as well as client side. Except for captcha systems .. that is if you are making your own use php :happy-04: .

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.