How we can use Use Javascript and asp validation control together

i make a Aspx.page On a Single button Click event i want to call both Required Field Validator And My Java Script Function My problem is that Required Field Validator return False and next Java Script Function returns true then page is executed which is wrong i want to restrict first one (if this is false ) how can i do it.

<asp:Button ID="btnViewReport" runat="server" class="button" Text="<%$ Resources:Resource, btnViewReport %>" OnClick="btnViewReport_Click" ValidationGroup="g1" OnClientClick="return Jvalidate();" />

g1 is my validtion group for requied field validatoe

thanks in advance

shashank


你可以这样写你的javascript:

    function Jvalidate() {

        var r = document.getElementById("yourRequiredFieldValidatorID");

        if (r.style.visibility == "hidden") {
            //Do your Stuff
            //Return the state accordingly.
        }
        else {
            return false;
        }
    }
链接地址: http://www.djcxy.com/p/74978.html

上一篇: 即使价值不真实,“真正的”评估仍在运行

下一篇: 我们如何使用Javascript和asp验证控件一起使用