Community Forums 

Main Content

Quantities changed by Shopper...hmmmm???

    Jan 30 2009 05:49:08

    #1

    Michael Schwab

    Join date : 2008-09-18      Posts : 87

    anon said: The javascript prevents them for putting non-whole numbers into the cart. noqty prevents them from changing them once they are there.

    Add to your form tag:
    onsubmit='return validate_qty(this.qty.value);'

    Add to page head:
    <script type='text/javascript'>
    function validate_qty(qty) {
    if(qty%1 != 0) {
    alert('Quantity must be a whole number');
    return false;
    }
    }
    </script>


    Ok I appreciate your efforts, but you lost me on this one:
    Add to your form tag:
    onsubmit='return validate_qty(this.qty.value);'



    Copy/paste didn't work on this one:
    Add to page head:
    <script type='text/javascript'>
    function validate_qty(qty) {
    if(qty%1 != 0) {
    alert('Quantity must be a whole number');
    return false;
    }
    }
    </script>


    I don't know what I did wrong.



    Jan 30 2009 13:08:09

    #2

    anon

    Join date : 2008-09-18      Posts : 488

    I don't know either. Link?



    Feb 01 2009 19:58:09

    #3

    maggoo

    Join date : 2009-01-30      Posts : 2

    Hello anon,

    I tried your solution, but cant make it work. Maybe you could spell it out some more. I have done the following to my form:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">;

    <html>
    <head>
    <script type='text/javascript'>
    function validate_qty(qty) {
    if(qty%1 != 0) {
    alert('Quantity must be a whole number');
    return false;
    }
    }
    </script>

    </head>

    <body>
    <form action="http://ww12.aitsafe.com/cf/add.cfm"; method="post">
    <input type="hidden" name="return" value="www.webl/" />
    <input type="hidden" name="userid" value="Exxxxx" />
    <input name="product" type="hidden" value="things">
    <input name="price" type="hidden" value="money">
    onsubmit='return validate_qty(this.qty.value);'
    </form>


    </body>
    </html>

    I guess the onsumit thingy is placed/used totally wrong, but i cant sort it out how it should work. Can you give me the proper syntax?

    TIA:P



    Feb 01 2009 21:15:54

    #4

    anon

    Join date : 2008-09-18      Posts : 488

    You have the onsubmit in the wrong place:

    <form action='http://ww12.aitsafe.com/cf/add.cfm' method='post' onsubmit='return validate_qty(this.qty.value);'>
    ...
    <input type='submit' value='Buy Now'>
    </form>



    Feb 01 2009 22:22:42

    #5

    maggoo

    Join date : 2009-01-30      Posts : 2

    Thank you anon!

    I use a quantity box now on the website itself, and send a noqty=3 to the shopping cart. Any tampering with the quantities in the cart or on the page are now as far as i can see not possible. On the webpage a pop up gives a warning when you type 0.5 orso, and in the cart you can only uncheck the amount.

    I do however agree with a previous poster that tampering with quantities in the cart should not be possible.



       «      1   |   2