chet139 Posted April 23, 2008 Share Posted April 23, 2008 I know its a bit of javascript to but its relevant to php aswell. function checkolineFields() //validation { if(oline.id.value.length >=1 && oline.qty.value.length >=1) { return true; } else { alert("Please provide the required data"); return false; } } I use this code to ensure both fields are filled in. ands it works so when submitting empty fields to cart - it wont let it happen. But once the cart has one item inside it and i go back to the form where the user can enter productID the validation seems to stop work any idea why. heres the other bit of relevent cod (perhaps) echo' <form name="oline" action="cart.php" onsubmit="return checkolineFields(this)" method="get"> <input type="hidden" name="action" value="add_item" /> <b>Product ID:</b> <br/><input type="text" name="id" size="9" maxlength="9" onKeyPress="return numbersonly(this, event)" /><br/> <b>Quantity:</b> <br/> <input type="text" name="qty" value="1" size="4" maxlength="4" onKeyPress="return numbersonly(this, event)" /><br/> <input type="hidden" name="orderId" value=" '. $orderId . '" /> <br/> <input type="submit" value="Add to Order" /> </form> Link to comment https://forums.phpfreaks.com/topic/102469-shopping-cart-validation/ Share on other sites More sharing options...
chet139 Posted April 23, 2008 Author Share Posted April 23, 2008 bump* Link to comment https://forums.phpfreaks.com/topic/102469-shopping-cart-validation/#findComment-524731 Share on other sites More sharing options...
chet139 Posted April 23, 2008 Author Share Posted April 23, 2008 *bump Link to comment https://forums.phpfreaks.com/topic/102469-shopping-cart-validation/#findComment-524829 Share on other sites More sharing options...
zenag Posted April 23, 2008 Share Posted April 23, 2008 can u pls...explain ur probs... in detail..... Link to comment https://forums.phpfreaks.com/topic/102469-shopping-cart-validation/#findComment-524831 Share on other sites More sharing options...
chet139 Posted April 23, 2008 Author Share Posted April 23, 2008 Hi thanks for the reply, but i literally just solved the problem. There was an error in the names of the forms. So the validation script was most likely getting confused. Thanks anyway. [sOLVED] Link to comment https://forums.phpfreaks.com/topic/102469-shopping-cart-validation/#findComment-524847 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.