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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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