嗨,我的所有设计Rad Panel bar
如下
<telerik:RadPanelBar runat="server" ID="rdpnlPersonal" ExpandMode="FullExpandedItem"
Skin="Vista" EnableEmbeddedSkins="false" Width="880px">
<Items>
<telerik:RadPanelItem Expanded="true" Text="Employee Personal Information" runat="server"
Selected="true">
<Items>
<telerik:RadPanelItem Value="AccountInformation" runat="server">
<ItemTemplate>
<label>
Demop
</label>
<telerik:RadDatePicker ID="RadDatePicker1" Width="200px" runat="server" MinDate="1900-01-01"
TabIndex="5">
<Calendar ID="Calendar1" RangeMinDate="1900-01-01" runat="server">
</Calendar>
</telerik:RadDatePicker>
<telerik:RadDatePicker ID="radDtHiredate" Width="200px" runat="server" MinDate="1900-01-01"
TabIndex="5">
<Calendar ID="calHire" RangeMinDate="1900-01-01" runat="server">
</Calendar>
</telerik:RadDatePicker>
<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="validatehiredate"
SetFocusOnError="true" ControlToValidate="radDtHiredate" ValidationGroup="accountValidation"
Display="Dynamic">Can not Hire Guy less than 18 yrs</asp:CustomValidator>
<br />
<telerik:RadButton ID="rdbtnwhAnother" Text="Add WithHolding" runat="server" ButtonType="LinkButton"
ValidationGroup="accountValidation" OnClick="rdbtnwhAnother_Click">
</telerik:RadButton>
</ItemTemplate>
</telerik:RadPanelItem>
</Items>
</telerik:RadPanelItem>
</Items>
</telerik:RadPanelBar>
这里我需要的是,如果所选日期小于18 years
我希望在Custom validator
. 为此,我编写了以下脚本,但我无法实现所需的..
我的脚本如下
<script type="text/javascript" language="javascript">
function monthDiff(d1, d2) {
alert("Mon");
var months;
var date1 = new Date(d1);
var date2 = new Date(d2);
return (date1 - date2) / (1000 * 60 * 60 * 24);
return months;
}
//function getLeapYear
function difference(d1, d2) {
var hiredate, dob; var diff = 18 * 12;
hiredate = document.getElementById(d1).get_selectedDate();
dob = document.getElementById(d2).get_selectedDate();
var Age = monthDiff(hiredate, dob);
var compareVal = 365 * 18; //getCompareVal(hiredate,dob);
if (Age >= compareVal) {
return true;
//true
} else {
return false; //false
}
}
function validatehiredate(value, arg) {
var datePicker = $find('<%# rdpnlPersonal.FindItemByText("Employee Personal Information").FindControl("RadDatePicker1").ClientID %>');
var datePicker1 = $find('<%# rdpnlPersonal.FindItemByText("Employee Personal Information").FindControl("radDtDOB").ClientID %>');
arg.IsValid = (difference(datePicker, datePicker1));
}
</script>
有人能帮助我吗