We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34017
    • 898 Posts
    Thought I would share my validation with you guys here. Took me a while to figure out. If anyone wants to modify/improve it, please feel free. Just want to help anyone else who needs it. Foxycart is sooooo open/flexible.

    <script language="javascript">
    
    // are these needed?
    var size = "";
    var color = "";
    
    //run this from the jquery function below
    function fc_PreProcess(color, size) {
    
    //clear error_string
    var	error_string = "";
    
    if (color == "") {	 error_string = error_string + "You must select a color.\n";	 }
    if (size == "") {	 error_string = error_string + "You must select a size.\n";	 }
    
    if (size == "" || color == "") {
    alert(error_string);
    return false;
    } else {
    return true;
    }
    }
    
    $j(function() {
    
    //run validation on forms with submit (if some products dont need this validation, you can give them a different class name)
    $j('.submit').bind('click', function() {
    
    //first drop-down item
    var size = $j(this).parents("form:first").find("select:eq(0)").val();
    //second drop down item
    var color = $j(this).parents("form:first").find("select:eq(1)").val();
    
    //run fc_PreProcess
    fc_PreProcess(color, size);
    if (size == "" || color == "") {
    //do not submit the form
    return false;
    }
    });
    </script>
    


    Also posted on Foxycart forums. http://forum.foxycart.com/comments.php?DiscussionID=195
      Chuck the Trukk
      ProWebscape.com :: Nashville-WebDesign.com
      - - - - - - - -
      What are TV's? Here's some info below.
      http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
      http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008