Hi, everyone. I am having difficulty with the following: I have a form with several RequiredFieldValidator controls on it. My user can take path 'A', down which all of these apply, or path 'B', down which only some of them apply. How can I 'disable' some of my validators (not all) so that when the form is submitted, these empty textboxes don't stop me? This is different from setting the CausesValidation property of a Cancel button to false. Thanks for any help! Steve--

Recommended Answers

All 2 Replies

Do not use validation controls. Use JavaScript.

Have a look at code snippet,

...
    <script type="text/javascript">
        function DoSubmit() {
            var btn = document.activeElement;
            if (btn.value == "A") {
                alert("Do this");
                return false;
            }
            else
            if (btn.value == "B") {
                alert("Do this");
                return false;
            }
        
            return true;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server" onsubmit="return DoSubmit()">
  
...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.