X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Validate Product options?? (https://forum.x-cart.com/showthread.php?t=61984)

ARW VISIONS 12-09-2011 08:24 PM

Validate Product options??
 
So i have about 20 product options and will have 500 - 600 products.

how can I validate them all using one script? don't want to have to put each product number and value in teh validation script.

ARW VISIONS 12-09-2011 08:35 PM

Re: Validate Product options??
 
ummmm... why is the value a number?

<option value="5908"> New Measurements </option>

this seems crazy. How am I going to validate all these product options? Am i going to have to know the value and product option number of 20 different options for 500 products?

ARW VISIONS 12-10-2011 05:30 AM

Re: Validate Product options??
 
Anyone? Was very doable in previous versions.

ARW VISIONS 12-13-2011 06:35 AM

Re: Validate Product options??
 
Used this. Also put it in a separate JS file so it would be global.

Code:

function validate_form(){
if (document.orderform[4].selectedIndex=='0')
 {
    alert('Please select whether you would like to use New Measurements or My Measurements.');
    return false;
 }
 else if(document.orderform[4].selectedIndex=='1')
 {
            var elem = (document.orderform.elements);
            var nelem = (elem.length*1) - (3*1);
           
                for(var i = 0; i < nelem; i++)
        {   
           
               
                if(document.orderform[i].type=='select-one')
                {
                        if(document.orderform[i].selectedIndex=='0')
                        {
                              alert('Please select all options.');
                                        return false;
                                }
                        }
                   
        }       
 }
else return true;
}


CottonAge.com 12-13-2011 01:00 PM

Re: Validate Product options??
 
did you figure this out?

ARW VISIONS 12-13-2011 01:10 PM

Re: Validate Product options??
 
yes used the above code to make all select boxes with a selected index of 0 alert please choose options.

you will probably have to revise.

CottonAge.com 12-13-2011 01:33 PM

Re: Validate Product options??
 
Ok, I was looking for something like this too. where i want my customers, If they select one option other will become mandatory

CottonAge.com 12-13-2011 01:41 PM

Re: Validate Product options??
 
but the way want is if the first option value is 1 then other option will be mandatory.


All times are GMT -8. The time now is 02:00 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.