简体   繁体   中英

Javascript Validation in Master Page and Content Place Holder

I'm using asp.net. I have a login form in Master page. I have written Javascript validation function for this in Master Page.

<table>
    <tr>
        <td>Username:></td>
        <td><asp:TextBox runat="server" id="txtUsername"/></td>
        <td>Password:></td>
        <td><asp:TextBox runat="server" id="txtPassword"/></td>
        <td>Username:></td>
        <td><asp:Button runat="server" id="btnLogin" Text="Login"/></td>
    </tr>
</table>

Also I am having Send Email form in Content Place Holder. I have written Javascript validation function for this in Content Place Holder.

 <table>
    <tr>
        <td>To:></td>
        <td><asp:TextBox runat="server" id="txtTo"/></td>
        <td>Password:></td>
        <td><asp:TextBox runat="server" id="txtEmail"/></td>
        <td>Username:></td>
        <td><asp:Button runat="server" id="btnSend" Text="Send"/></td>
    </tr>
 </table>

My Issue is when I click on the btnSend button, the validations of Login form are occurring?

Edited: Solution: The problem is I am using the same validation function name for both the Master Page and Content Place Holder. I changed the Validation function name in the Master Page and that resolved the issue

If you have server side validations you can disable them in your javascript function as shown below:

ValidatorEnable("reqValId", false);

To Enable:

ValidatorEnable("reqValId", true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM