Jump to content


Photo

Form Validation Script - required attribute for lists

form validation required lists

  • Please log in to reply
4 replies to this topic

#1 wicksworks

wicksworks

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 29 September 2013 - 11:15 PM

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.

 

 

Attached Files



#2 wicksworks

wicksworks

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 30 September 2013 - 09:41 AM

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>
</select>

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

 

Thanks in advance!



#3 darkfreaks

darkfreaks

    Advanced Member

  • Members
  • PipPipPip
  • 4,942 posts
  • LocationAustin,Texas

Posted 30 September 2013 - 03:51 PM

http://www.html-form...validation.html

 

 

should read how to use the class first. maybe you would get more of an idea how it works.



#4 cyber_alchemist

cyber_alchemist

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts

Posted 01 October 2013 - 05:58 AM

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: .



#5 wicksworks

wicksworks

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 05 October 2013 - 12:14 PM

http://www.html-form...validation.html

 

 

should read how to use the class first. maybe you would get more of an idea how it works.

 

I have read the documentation and clearly still do not understand it. Hence, back to the top of the "help" loop. :-)






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com