chet139 Posted April 23, 2008 Share Posted April 23, 2008 Hi, I have a bit of javascript which does what its suppose to do just fine. See below: 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; } } However upon submitting something to another page (adding something to a cart) - and then coming back to the page with the validation, the validation check no longer works. Here the other bit of code thats probably related: 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> any ideas why it stops working after when it works the first time round before anything is added to cart. Link to comment https://forums.phpfreaks.com/topic/102473-javascript-validation-ignored-upon-reentering-page/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.