有谁能解释一下下面的javascript语法吗?

Can any one explain me the below syntax in javascript?

本文关键字:javascript 语法 能解释 一下      更新时间:2023-09-26

谁能给我解释一下下面的java脚本语法,因为我是java脚本新手,我无法理解下面的代码。

function validateAll(adMode, primaryAssetType, adCompanionAssetType) {
    var check = adStickervalidationcheck(adMode, 'new', primaryAssetType, adCompanionAssetType);
    if(check == true) {
        check=calculateTotalnoofImpression('${campaignid}');    
    }
    return check;   
}

在上面的代码中为什么关键字new作为参数传递而不使用任何对象。

下面是函数定义代码:
function adStickervalidationcheck(assetFormType,type,primaryAssetType,adCompanionAssetType)
{
    if((trim(document.assetform.priority.value))=="select")
    {
        alert("Please select the priority.");
        return false;
    }
    if((trim(document.assetform.impression.value).length)==0)
    {
        alert("Please enter Total Number of Impression.");
        return false;
    }
    if((trim(document.assetform.impression.value))=="0")
    {
        alert("Total No. Of Impression should not be Zero(0).");
        return false;
    }
    if(primaryAssetType=="Picture" || primaryAssetType=="Picture+Audio")
    {
        if((trim(document.assetform.picExt.value))=="select")
        {
            alert("Please select the extension of primary Image Asset File");
            return false;
        }
        if(type!="edit")
        {
            if((trim(document.assetform.asset_import.value))=="")
            {
                alert("Please import the primary Image Asset File");
                return false;
            }
        }
    }
    if(primaryAssetType=="Audio" || primaryAssetType=="Picture+Audio")
    {
        if((trim(document.assetform.audExt.value))=="select")
        {
            alert("Please select the extension of primary Audio Asset File");
            return false;
        }
        if(type!="edit")
        {
            if((trim(document.assetform.asset_import_audio.value))=="")
            {
                alert("Please import the primary Audio Asset File");
                return false;
            }
        } 
    }

    if(adCompanionAssetType.contains("Picture") || adCompanionAssetType.contains("Video") || adCompanionAssetType.contains("Audio"))
    {
        if((trim(document.assetform.companion_assettype.value))=="select")
        {
            alert("Please select the extension of companion Asset File");
            return false;
        }
        if(type!="edit")
        {
            if((trim(document.assetform.asset_import2.value))=="")
            {
                alert("Please import the companion Asset File");
                return false;
            }
        }
    }
    if(adCompanionAssetType.contains("Audio") && adCompanionAssetType.contains("Picture"))
    {
        if((trim(document.assetform.companion_audio_Asset.value))=="select")
        {
            alert("Please select the extension of companion Audio Asset File");
            return false;
        }
        if(type!="edit")
        {
            if((trim(document.assetform.asset_import4.value))=="")
            {
                alert("Please import the companion Media Asset File");
                return false;
            }
        }
    }
    if(adCompanionAssetType.contains("Video") && adCompanionAssetType.contains("Picture"))
    {
        if((trim(document.assetform.companion_video_Asset.value))=="select")
        {
            alert("Please select the extension of companion Video Asset File");
            return false;
        }
        if(type!="edit")
        {
            if((trim(document.assetform.asset_import4.value))=="")
            {
                alert("Please import the companion Media Asset File");
                return false;
            }
        }
    }
    if(adCompanionAssetType.contains("URL"))
    {
        if((trim(document.assetform.UrlAssetfile.value).length)==0)
        {
            alert("Please enter the companion URL Asset File");
            return false;
        }
    }

    if(assetFormType=="Subscriber" || assetFormType=="User")
    {

        if((document.assetform.male.checked==false) && (document.assetform.female.checked==false))
        {
            alert("Please Choose Gender. ");
            return false;
         }
        if((document.assetform.agegroup1.checked==false) &&
            (document.assetform.agegroup2.checked==false)&&
                (document.assetform.agegroup3.checked==false) &&
                    (document.assetform.agegroup4.checked==false))
                    {
                        alert("Please choose atleast one of the Age Group.");
                        return false;
                    }
         if((document.assetform.professiongroup1.checked==false) &&
            (document.assetform.professiongroup2.checked==false)&&
                (document.assetform.professiongroup3.checked==false) &&
                    (document.assetform.professiongroup4.checked==false) &&
                        (document.assetform.professiongroup5.checked==false)&&
                            (document.assetform.professiongroup6.checked==false))
                            {
                                alert("Please choose atleast one of the Profession.");
                                return false;
                            }
         if((trim(document.assetform.targetCity.value).length)==0)
            {
                alert("Please enter the targetCity");
                return false;
            }
         if((trim(document.assetform.targetArea.value).length)==0)
            {
                alert("Please enter the targetArea");
                return false;
            }
         if((trim(document.assetform.targetPincode.value).length)==0)
            {
                alert("Please enter the targetPinCode");
                return false;
            }

    }
     return true;
}

函数的作用是验证所有"Assets"的表单条目是否有效。

如果你的资产类型是"new"或"edit",则验证(有点笨拙)是不同的。

你所谓的关键字"new"只是一个字符串,因为验证规则不同,它可以区分我们是想检查表单是添加还是修改。