0
我在我的各種類型的頁面上有許多ASP.NET驗證器,其中一些我使用javascript取決於頁面上的用戶選擇而禁用。CustomValidator問題
這似乎是工作和驗證器不火,除了任何CustomValidators所有的情況下,我使用時,我不能使用其他類型的驗證
<asp:CheckBoxList id="BodyPartsList" runat="server" RepeatColumns = "2"
Width="1023px">
<asp:ListItem Text = "0. Head/headaches" Value = "1"></asp:ListItem>
<asp:ListItem Text = "1. Leg(s)" Value = "2"></asp:ListItem>
<asp:ListItem Text = "2. Arm(s)" Value = "3"></asp:ListItem>
<asp:ListItem Text = "3. Neck" Value = "4"></asp:ListItem>
<asp:ListItem Text = "4. Shoulder(s)" Value = "5"></asp:ListItem>
<asp:ListItem Text = "5. Low Back" Value = "6"></asp:ListItem>
<asp:ListItem Text = "6. Upper Back" Value = "7"></asp:ListItem>
<asp:ListItem Text = "7. Feet" Value = "8"></asp:ListItem>
<asp:ListItem Text = "8. Hand(s)" Value = "9"></asp:ListItem>
<asp:ListItem Text = "9. Other(Describe in "Details of Plan")" Value = "10"></asp:ListItem>
</asp:CheckBoxList>
<asp:CustomValidator ID="PainLocationValidator" runat="server" Display="Dynamic"
ErrorMessage="Location of pain is required."
ClientValidationFunction="checkPainListValidate"
ValidationGroup = "OnSave" EnableClientScript= "true" SetFocusOnError= "true" Width = "100%" CssClass = "pain" />
function checkPainListValidate(sender, args) {
args.IsValid = true;
if ($('#<%= BodyPartsList.ClientID %> input:checked').length > 0)
args.IsValid = true;
else
args.IsValid = false;
}
這究竟是爲什麼?還有什麼我可以做的,以禁用這些呢?
謝謝。
感謝答覆和一些有用的想法1.我沒有想到第一個想法2.我在客戶端驗證它,所以使用ClientValidationFunction,看到更新3.我沒有指定ControlToValidate,因爲它是一個複選框列表,如果我有錯誤去做。 4.如果你禁用驗證器,它會在每次回發中驗證嗎? – Victor 2011-02-08 22:34:03