Make All the Invalid Fields Show Upon Submit NOT Just One at a Time

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Make All the Invalid Fields Show Upon Submit NOT Just One at a Time

    I need a hand to get this to show all the arrows (display block) at once instead of one at a time:

    Code:
    function remove(id)
    	{
    		if(confirm('Are you sure you want to delete this product from your cart?'))
    		{
    			document.getElementById("frmCart").action="cart.php?id="+id;
    			document.getElementById("frmCart").submit();
    		}
    	}
    	
    	function isemail(obj)
    	{ 
    		var objRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
    		var test = objRegExp.test(obj.value);
    		if(test == false)
    		{
    			return false;
    		}
    		return true;
    	}
    
    	function chkfrmcontactus()
     {var result = true;
    		document.getElementById('selectx').style.display="none";
    		document.getElementById('txtfnamex').style.display="none";
    		document.getElementById('txtlnamex').style.display="none";
    		document.getElementById('txtemailx').style.display="none";
    		document.getElementById('txtphonex').style.display="none";
    		document.getElementById('txtaddressx').style.display="none";
    		document.getElementById('txtcityx').style.display="none";
    		document.getElementById('txtstatex').style.display="none";
    		document.getElementById('txtzipx').style.display="none";
    		
    		document.getElementById('billing_addressx').style.display="none";
    		document.getElementById('billing_cityx').style.display="none";
    		document.getElementById('billing_statex').style.display="none";
    		document.getElementById('billing_zipx').style.display="none";
    		document.getElementById('billing_countryx').style.display="none";
    
    		document.getElementById('cc1x').style.display="none";
    		document.getElementById('cc2x').style.display="none";
    		document.getElementById('cc3x').style.display="none";
    		document.getElementById('cc4x').style.display="none";
    		document.getElementById('ccexpx').style.display="none";
    		document.getElementById('c_v_cx').style.display="none";
    		document.getElementById('agreex').style.display="none";
    		document.getElementById('mpx').style.display="none";
    		document.getElementById('m-p-nx').style.display="none";
    		document.getElementById('mpamtx').style.display="none";
    		
    		
    
    		if(document.getElementById("mnp").checked && document.getElementById("m-p-1").value.length < 14)
    {
       document.getElementById("m-p-1").focus();
            document.getElementById('mxp').style.display="block";
            return false;
    }  
     
     
    		if(document.getElementById("creditcard").checked && document.getElementById("cc1").value.length < 4)
    {
       document.getElementById("cc1").focus();
            document.getElementById('cc1x').style.display="block";
            return false;
    }  
    		if(document.getElementById("creditcard").checked && document.getElementById("cc2").value.length < 4)
    {
       document.getElementById("cc2").focus();
            document.getElementById('cc2x').style.display="block";
            return false;
    
    }  
    		if(document.getElementById("creditcard").checked && document.getElementById("cc3").value.length < 4)
    {
       document.getElementById("cc3").focus();
            document.getElementById('cc3x').style.display="block";
            return false;
    
     }  
    		if(document.getElementById("creditcard").checked && document.getElementById("cc4").value.length < 4)
    {
       document.getElementById("cc4").focus();
            document.getElementById('cc4x').style.display="block";
            return false;
    
     } 		if(document.getElementById("creditcard").checked && document.getElementById("ccexp").value.length < 4)
    {
       document.getElementById("ccexp").focus();
            document.getElementById('ccexpx').style.display="block";
            return false;
    
     } 
    
    		if(document.getElementById("creditcard").checked && document.getElementById("c_v_c").value.length < 3)
    {
       document.getElementById("c_v_c").focus();
            document.getElementById('c_v_cx').style.display="block";
            return false;
    }  
    		if(document.getElementById("split").checked && document.getElementById("m-p-n").length < 14)
    {
       document.getElementById("m-p-n").focus();
            document.getElementById('m-p-x').style.display="block";
            return false;
    }  
    
      if(document.getElementById("txtfname").value == "")
    		{
    			document.getElementById("txtfname").focus();
    						document.getElementById('txtfnamex').style.display="block";
    			return false;
    		}
    		else if(document.getElementById("txtlname").value == "")
    		{
    						document.getElementById('txtlnamex').style.display="block";
    			document.getElementById("txtlname").focus();
    			
    			return false;
    		}
    		else if(document.getElementById("txtemail").value.length < 8)
    		{
    						document.getElementById('txtemailx').style.display="block";
    			document.getElementById("txtemail").focus();
    			return false;
    		}
    		else if(!isemail(document.getElementById("txtemail")))
    		{
    			alert("Please enter a valid Email address.");
    			document.getElementById("txtemail").focus();
    			document.getElementById('txtemailx').style.display="block";
    			return false;
    		}
    		else if(document.getElementById("txtphone").value.length < 10)
    		{
    			document.getElementById("txtphone").focus();
    			document.getElementById('txtphonex').style.display="block";
    			return false;
    		}
    		else if(document.getElementById("txtaddress").value == "")
    		{
    			document.getElementById("txtaddress").focus();
    			document.getElementById('txtaddressx').style.display="block";
    			return false;
    		}
    		else if(document.getElementById("txtcity").value == "")
    		{
    			document.getElementById("txtcity").focus();
    			document.getElementById('txtcityx').style.display="block";
    			return false;
    		}
    		else if(document.getElementById("txtstate").value == "")
    		{
    			document.getElementById("txtstate").focus();
    			document.getElementById('txtstatex').style.display="block";
    			return false;
    		}
    		else if(document.getElementById("txtzip").value == "")
    		{
    			document.getElementById("txtzip").focus();
    			document.getElementById('txtzipx').style.display="block";
    			return false;
    		}
    		else if(document.getElementById("txtcountry").value == "")
    		{
    			document.getElementById("txtcountry").focus();
    			document.getElementById('txtcountryx').style.display="block";
    			return false;
    	
    	
    		}
    		if(!document.getElementById("billing").checked)
    		{
    			if(document.getElementById("billing_address").value == "")
    			{	
    				document.getElementById("billing").focus();
    				document.getElementById('billing_addressx').style.display="block";
    				return false;
    			}
    			else if(document.getElementById("billing_city").value == "")
    			{
    		
    				document.getElementById("billing").focus();
    				document.getElementById('billing_cityx').style.display="block";
    				return false;
    			}
    			else if(document.getElementById("billing_state").value == "")
    			{
    			document.getElementById("billing_state").focus();
    				document.getElementById('billing_statex').style.display="block";
    				return false;
    		}
    				else if(document.getElementById("billing_zip").value.length < 2)
    			{
    				document.getElementById("billing_zip").focus();
    				document.getElementById('billing_zipx').style.display="block";
    				return false;
    			}
    		
    			else if(document.getElementById("billing_country").value == "")
    			{
    			document.getElementById("billing_country").focus();
    				document.getElementById('billing_countryx').style.display="block";
    				return false;
    		
    				
    			}}
    if (!document.getElementById("mnp").checked &&
    !document.getElementById("creditcard").checked && 
    !document.getElementById("split").checked)
    	{
    	document.getElementById("billing").focus();
    		document.getElementById('selectx').style.display="block";
    		return false;
    				  }
    		
    			else if(!document.getElementById("agree").checked)
    			{
    				document.getElementById("agree").focus();
    				document.getElementById('agreex').style.display="block";
    				return false;
    		
    			}
    		
    		document.getElementById("form").submit();
    		}
Working...
X