有谁能解释一下下面的javascript语法吗?
Can any one explain me the below syntax in javascript?
谁能给我解释一下下面的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"只是一个字符串,因为验证规则不同,它可以区分我们是想检查表单是添加还是修改。
相关文章:
- Javascript语法向设置发出sessionStorage值
- 函数的Javascript语法
- 如何定义const函数javascript(语法糖)
- Onclick不会启动..可能存在javascript语法问题
- 用jquery替换javascript语法
- 在Javascript语法中:和::和:::有什么区别
- 如何以编程方式查找javascript语法错误的位置
- 这个javascript语法有什么问题
- Chrome 中的 JSX/JavaScript 语法
- Javascript语法 - 我做错了什么
- 用于指定元素 ID 的正确 JavaScript 语法是什么
- 这是什么JavaScript语法
- 带有函数的 JavaScript 语法
- 剃刀中的javascript语法错误
- 解析云代码geoPoint查询Javascript语法
- 在Notepad++中更好地突出显示Javascript语法
- 通用Javascript语法查询
- Joomla2.5框架似乎干扰了javascript语法
- 点击切换Divs/JavaScript语法
- 用于将变量传递给函数的javascript语法