

<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>
		<title>LexiConn News  &#187;  Topic: Prevent empty form submissions in multi-add-to-cart forms</title>
		<atom:link href="https://support.lexiconn.com/news/forums/topic/prevent-empty-form-submissions-in-multi-add-to-cart-forms/feed" rel="self" type="application/rss+xml" />
		<link>https://support.lexiconn.com/news/forums/topic/prevent-empty-form-submissions-in-multi-add-to-cart-forms/feed</link>
		<description></description>
		<pubDate>Mon, 06 Apr 2026 01:36:16 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.5.3-5249</generator>
		<language>en-US</language>

		
														
					
				<item>
					<guid>https://support.lexiconn.com/news/forums/topic/prevent-empty-form-submissions-in-multi-add-to-cart-forms/#post-48718</guid>
					<title><![CDATA[Prevent empty form submissions in multi-add-to-cart forms]]></title>
					<link>https://support.lexiconn.com/news/forums/topic/prevent-empty-form-submissions-in-multi-add-to-cart-forms/#post-48718</link>
					<pubDate>Mon, 25 Jan 2010 21:24:09 +0000</pubDate>
					<dc:creator>Anonymous</dc:creator>

					<description>
						<![CDATA[
						<p>If you create a multi-add-to-cart form that allows a customer to add an empty order to the cart, the customer will receive a shopping cart error that could lose a sale. To prevent these errors, you will need to add javascript-based form validation to your multi-add-to-cart form, preventing empty orders from being submitted.</p>
<p>Here is the procedure for adding empty cart validation to your multi-add-to-cart forms:</p>
<p>1. Edit your opening add-to-cart</p>
<form>element to have a name and onsubmit attribute as follows:</form>
<p>&nbsp;</p>
<pre>&lt;form name="add" action="http://www.your_domain.com/cgi-your_domain/sb/order.cgi" onsubmit="return(validateForm())" /&gt;

</pre>
<p>&nbsp;</p>
<p>2. Add the following Javascript to theregion of your page:</p>
<p>&nbsp;</p>
<pre>&lt;script type="text/javascript"&gt; 
 function validateForm(){ 
 
   if (document.add.itemnum.length) { 
        for(n=0; n&lt;document.add.itemnum.length; n++){ 
                if(document.add.itemnum[n].checked == true){ 
                      return true; 
                } 
        } 
   } 
   else { 
         if(document.add.itemnum.checked == true){ 
                 return true; 
         } 
   } 
        alert("Please select at least one item to add to the cart."); 
        return false; 
 } 
 &lt;/script&gt; 

</pre>
<p>&nbsp;</p>
<p>3. (optional) Customize the text that is displayed if a customer tries to add an empty form to the cart in (be careful not to delete either of the double-quotes):</p>
<p>&nbsp;</p>
<pre>alert("Please select at least one item to add to the cart.")

</pre>
<p>&nbsp;</p>
<p>4. Make certain that the &#8220;name&#8221; attribute of your form (</p>
<form name="">&nbsp;</p>
<pre>&lt;form name="add" ... /&gt; 
 . 
 . 
 . 
 &lt;script type="text/javascript"&gt; 
 function validateForm(){ 
 
   if (document.add.itemnum.length) { 
        for(n=0; n&lt;document.add.itemnum.length; n++){ 
                if(document.add.itemnum[n].checked == true){ 
                      return true; 
                } 
        } 
   } 
   else { 
         if(document.add.itemnum.checked == true){ 
                 return true; 
         } 
 . 
 . 
 . 

</pre>
<p>&nbsp;</p>
<p>Now your multi-add-to-cart form will not allow blank forms to be submitted to the cart, and will notify customers that they have not selected anything if they try to.</p>
</form>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

