...

View Full Version : Disable form validation on disabled fields



knox203
09-10-2008, 11:37 PM
Can anyone help me modify this script to bypass validation on fields that are disabled? Thanks!



<!--

/***********************************************
* 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;
}
}
// -->

Arty Effem
09-11-2008, 12:10 AM
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.

knox203
09-11-2008, 12:14 AM
I knew it was going to be something quick and easy. Thanks so much Arty, you tha man!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum