Log in

View Full Version : Form validation script for client side cart



jumpink
05-14-2007, 03:22 AM
I have a client side shopping cart. The problem is with my form. If someone does not choose a size from the drop down menu it will still add to cart. I want an error message to pop up if no size is chosen. Here is my form
<form action = "javascript: void 0;"
method = "post"
onsubmit = "SetDesc ('shirt');
SetCode ('ts00014');
SetImg ('images/cartimage/shirt.gif');
SetPcat (2);
if (ReadForm (this, true))
CallView ();
ClearAll ();
return false;">

$17.95 -
<input type="hidden" name="initer" value=" @0" />
<select size="1" name="size">

<option selected value="Select a size">Select a size</option>
<option value = "Small @17.95">Small</option>
<option value = "Medium @17.95">Medium</option>
<option value = "Large @17.95">Large</option>
<option value = "X-Large @17.95">XL</option>
<option value = "2XL @19.95">2X ($2)</option>
</select>
<input type = "submit"
name = "submit"
value = "add to cart" />

<br /><br />
Input <b>Quantity</b> to order -
<input type = "text"
name = "qty"
value = "1"
size = "4" />
<br /><br />
</p>
</form>I found a form validation script at http://www.dynamicdrive.com/dynamicindex16/requiredcheck.htm
Not sure how to customize it to work in my script. Here is my script http://www.precisemessenger.com/private/cart1.js
Any help is appreciated.
Thanks