Jump to content

javascript validation ignored upon reentering page


chet139

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.