I am building a form for my business that has a lot of hidden fields.
Since I am hiding and showing fields due to different selections the users make, I want to validate only visible forms fields.
Here is my small form on a website.
I don't have the validation script up there currently because the javascript I have requires me to enter in all the fields that are required and then will 'validate' those by checking if they are null or "". But I can't know which ones will be shown to the users so I have to enter all the fields as required. This isn't good because the users won't know why the fields they can't see are required.
I also found this thread [thread216-1481039] where someone was asking the same question but it must have died before it was answered.
Here's some of js I currently have checking for validation. Again all I really want is to validate visible fields:
Since I am hiding and showing fields due to different selections the users make, I want to validate only visible forms fields.
Here is my small form on a website.
I don't have the validation script up there currently because the javascript I have requires me to enter in all the fields that are required and then will 'validate' those by checking if they are null or "". But I can't know which ones will be shown to the users so I have to enter all the fields as required. This isn't good because the users won't know why the fields they can't see are required.
I also found this thread [thread216-1481039] where someone was asking the same question but it must have died before it was answered.
Here's some of js I currently have checking for validation. Again all I really want is to validate visible fields:
Code:
function formCheck(formobj){
var fieldRequired = Array("issue_type", "part_num", "order_num");
var fieldDescription = Array("issue_type", "part_num", "order_num");
var alertMsg = "Please complete the following fields:\n";
for (var i = 0; i < fieldRequired.length; i++){
var obj = formobj.elements[fieldRequired[i]];
if (obj){
switch(obj.type){
...........case statements checking for null or ""......
if (alertMsg.length == l_Msg){
return true;
}else{
alert(alertMsg);
return false;
}
}