2015-08-27 40 views
-1

任何人都可以在java腳本中展示下面的語法,因爲我是java腳本的新手我無法理解下面的代碼。任何人都可以解釋我在JavaScript中的下面的語法?

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; 
} 
+12

我不認爲'新'是一個關鍵詞,因爲它被**引用**,它的一個字符串! –

+1

沒有看到'adStickervalidationcheck'函數沒有人可以告訴你。提供'adStickervalidationcheck'功能代碼。 – atinder

+1

你發現哪些代碼片段特別不清楚?你不懂什麼語法? –

回答

0

你的功能不被驗證,如果你的全部「資產」的形式進入是有效的。

如果您的資產類型爲「新建」或「編輯」,那麼(笨拙的)驗證方式會有所不同。

你稱爲關鍵字「new」的只是一個字符串,它區分了如果我們想要檢查表單的添加或版本,因爲驗證規則是不同的。

相關問題