0
我的网页有三个视图,第二个视图我想验证一个JavaScript函数。如果我不添加这个函数,那么require字段验证工作正常,而我添加这个JavaScript函数,并尝试调用页面加载require字段验证是行不通的。要求字段验证在添加其他JavaScript时不起作用
function checkDate()
{
var dt = new Date();
var month =1 + dt.getMonth();
var day = dt.getDate();
var e = document.getElementById("<%=PurchMonth.ClientID%>");
var monthvalue = e.options[e.selectedIndex].value;
var e1 = document.getElementById("<%=PurchDay.ClientID%>");
var dayvalue = e1.options[e1.selectedIndex].value;
if (monthvalue < month)
{
return true;
}
else if (monthvalue ==month)
{
if (dayvalue>day)
{
alert("Future Date is not allowed");
return false;
}
else
{
return true;
}
}
else
{
alert("Future Date is not allowed");
return false;
}
}
protected void Page_Load(object sender, EventArgs e)
{
btnModelsNext.Attributes.Add("onclick", "return checkDate();");
}