Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Disable form validation on disabled fields

    Can anyone help me modify this script to bypass validation on fields that are disabled? Thanks!

    Code:
    <!--
    
    /***********************************************
    * Required field(s) validation v1.10- By NavSurf
    * Visit Nav Surf at http://navsurf.com
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    function formCheck(formobj){
    	// Enter name of mandatory fields
    	var fieldRequired = Array("route1_1", "route1_2", "route2_1", "route2_2", "route3_1", "route3_2", "route4_1", "route4_2", "route5_1", "route5_2", "route6_1", "route6_2", "route7_1", "route7_2");
    	// Enter field description to appear in the dialog box
    	var fieldDescription = Array("Day 1: Route 1", "Day 1: Route 2", "Day 2: Route 1", "Day 2: Route 2", "Day 3: Route 1", "Day 3: Route 2", "Day 4: Route 1", "Day 4: Route 2", "Day 5: Route 1", "Day 5: Route 2", "Day 6: Route 1", "Day 6: Route 2", "Day 7: Route 1", "Day 7: Route 2");
    	// dialog message
    	var alertMsg = "Please complete the following fields:\n";
    	
    	var l_Msg = alertMsg.length;
    	
    	for (var i = 0; i < fieldRequired.length; i++){
    		var obj = formobj.elements[fieldRequired[i]];
    		if (obj){
    			switch(obj.type){
    			case "select-one":
    				if (obj.selectedIndex == 0 || obj.options[obj.selectedIndex].text == ""){
    					alertMsg += " - " + fieldDescription[i] + "\n";
    				}
    				break;
    			case "select-multiple":
    				if (obj.selectedIndex == 0){
    					alertMsg += " - " + fieldDescription[i] + "\n";
    				}
    				break;
    			case "text":
    			case "textarea":
    				if (obj.value == "" || obj.value == null){
    					alertMsg += " - " + fieldDescription[i] + "\n";
    				}
    				break;
    			default:
    			}
    			if (obj.type == undefined){
    				var blnchecked = false;
    				for (var j = 0; j < obj.length; j++){
    					if (obj[j].checked){
    						blnchecked = true;
    					}
    				}
    				if (!blnchecked){
    					alertMsg += " - " + fieldDescription[i] + "\n";
    				}
    			}
    		}
    	}
    
    	if (alertMsg.length == l_Msg){
    		return true;
    	}else{
    		alert(alertMsg);
    		return false;
    	}
    }
    // -->

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Code:
    	for (var i = 0; i < fieldRequired.length; i++){
    		var obj = formobj.elements[fieldRequired[i]];
    		if (obj && !obj.disabled){
    			switch(obj.type){
    			case "select-one":
    				if
    Just add the bold text.

  • Users who have thanked Arty Effem for this post:

    knox203 (09-11-2008)

  • #3
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I knew it was going to be something quick and easy. Thanks so much Arty, you tha man!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •