0
我想驗證基於下拉列表的文本框,例如,如果DDL值是「天」,文本框的值不能超過31似乎無論什麼我進入觸發我的自定義驗證錯誤,我究竟做錯了,多虧:JavaScript的文本框驗證火災自定義驗證錯誤不管值
<asp:TextBox ID="uitxtCamLastVisitDur" runat="server" CssClass="tooltip"
Width="65px" Enabled="False" ToolTip="Indicates a required spending on the member's last visit."></asp:TextBox>
<asp:CustomValidator ID="ccvLastVisitDuration" runat="server"
ClientValidationFunction="validateDurationType"
ControlToValidate="uitxtCamLastVisitDur"
ErrorMessage="Duration input error"></asp:CustomValidator>
function validateDurationType(src, args) {
if (document.getElementById('<%= uiddlCamLastVisitDurType.ClientID%>').selectedIndex == 1)
if (parseInt(document.getElementById('<%= uitxtCamLastVisitDur.ClientID%>').value < 0) || (parseInt(document.getElementById('<%= uitxtCamLastVisitDur.ClientID%>').value > 31))) {
args.IsValid = false;
return;
}
if (document.getElementById('<%= uiddlCamLastVisitDurType.ClientID%>').selectedIndex == 2)
if (parseInt(document.getElementById('<%= uitxtCamLastVisitDur.ClientID%>').value < 0) || (parseInt(document.getElementById('<%= uitxtCamLastVisitDur.ClientID%>').value > 12))) {
args.IsValid = false;
return;
}
args.IsValid = true;
}