function CheckInputInfo()
{
var str=/(^[1-9]+\d*\.\d{1,3}$)|(^0\.\d{1,3}$)|^[1-9]*$|^0$/;
var PtnNo=document.getElementById("<%=txtPtnNo.ClientID%>");
var BOM=document.getElementById("<%=txtAreaVersion.ClientID%>");
var PriceFactor=document.getElementById("<%=dplPriceFactor.ClientID%>");
var SubSectionFlag =document.getElementById("<%=dplSubSectionFlag.ClientID%>");
var Price=document.getElementById("<%=txtPrice.ClientID%>");
var EnableDate=document.getElementById("<%=txtEnableDate.ClientID%>");
var InvalideDate=document.getElementById("<%=txtInvalideDate.ClientID%>");
var Goods=document.getElementById("<%=txtGoods.ClientID%>");
var Currency=document.getElementById("<%=dplCurrency.ClientID%>");
if(PtnNo.value=="")
{
event.returnValue=false;
window.alert("請輸入電腦形體號!");
}
else if(BOM.value=="")
{
event.returnValue=false;
window.alert("請輸入BOM版次!");
}
else if(EnableDate.value=="")
{
event.returnValue=false;
window.alert("請輸入生效日期!");
}
else if(InvalideDate.value=="")
{
event.returnValue=false;
window.alert("請輸入失效日期!");
}
else if(EnableDate.value!=""&&InvalideDate.value!="")
{
var d1=new Date(EnableDate.value.replace("-","/"))
var d2=new Date(InvalideDate.value.replace("-","/"))
var strDate1=Date.parse(d1);
var strDate2=Date.parse(d2);
if(strDate2-strDate1<0)
{
event.returnValue=false;
window.alert("失效日期必須大于生效日期!");
}
}
else if(PriceFactor.options.length>0)
{
if(PriceFactor.selectedIndex==0)
{
event.returnValue=false;
window.alert("請選擇報價因素!");
}
}
else if(Price.value=="")
{
event.returnValue=false;
window.alert("請輸入單價!!");
}
else if(Price.value!="")
{
if(!str.test(Price.value))
{
event.returnValue=false;
window.alert("單價只能為數字!!\n例如:123或者1.12");
}
}
else if(Currency.selectedIndex==0)
{
event.returnValue=false;
window.alert("請選擇幣別!");
}
}是我写的有问题吗
现在只能判断到else if(EnableDate.value!=""&&InvalideDate.value!="")这里
在往下就不判断了 是不是 if else 写多了?
swithc(i){
case 1:
语句1;
case 2:
语句2;
}多好
{
... ...
}
else if(Price.value!="")
{
... ...
}... ...你认为走完这两个 else if 还会有什么可能往下走呢?
在C#里这样写没问题啊
---------------------------------------------
语法是没问题,但结果肯定不对了.你应该对每一项检查的话各走一个if else.而不应该放在一个if elseif 中.
比如 if(Price.value=="")
{
event.returnValue=false;
window.alert("請輸入單價!!");
}
else //if(Price.value!="")
{
if(!str.test(Price.value))
{
event.returnValue=false;
window.alert("單價只能為數字!!\n例如:123或者1.12");
}
} if(Currency.selectedIndex==0)
{
event.returnValue=false;
window.alert("請選擇幣別!");
}
else
{ ... } if(...)
else
...
{
return false;
}