1

例如,如果我选择了整个表单,我将在 asp.net webform中使用jquery.dirtyforms

$('#form1').dirtyForms();
框架工作正常但是当我只需要在下面的表单中选择 div 时出现我的问题是我的代码:

    <script type="text/javascript">
        $(document).ready(function () {
            $("form").dirtyForms({
                message: 'يبدو انك نسيت تحفيظ المعلومات , في حال الانتقال لصفحة اخرى سوف تخسر معلوماتك !',
                dialog: {
                    open: function (choice, message) {
                        $.blockUI({
                            message: '<span class="dirty-dialog">' +
                                    '<h3>هل انت متاكد انك تريد ترك الصفحة؟</h3>' +
                                    '<p>' + message + '</p>' +
                                    '<span>' +
                                        '<button type="button" class="dirty-proceed">اترك الصفحة</button> ' +
                                        '<button type="button" class="dirty-stay">ابق هنا</button>' +
                                    '</span>' +
                                '</span>',
                            css: {
                                width: '400px',
                                padding: '10px',
                                cursor: 'auto',
                                color: 'red',
                                background: '#ffffe6'
                            },
                            overlayCSS: {
                                cursor: 'auto'
                            },
                        });


                        choice.staySelector = '.dirty-dialog .dirty-stay,.blockOverlay';
                        choice.proceedSelector = '.dirty-dialog .dirty-proceed';
                    },
                    close: function () {
                        $.unblockUI();
                    }
                },

            });

        });

    </script>
<form id="form1" runat="server">
        <div>
            <p><a href="Default2.aspx" id="modal">Modal Link</a></p>
            <a href="http://google.com">google</a>

        </div>
        <div id="form2" class="form-inline">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <th colspan="3">Registration
                    </th>
                </tr>
                <tr>
                    <td>Username :
                    </td>
                    <td>
                        <asp:TextBox ID="txtUsername" runat="server" />
                    </td>
                    <td>
                        <asp:RequiredFieldValidator ErrorMessage="Required" ForeColor="Red" ControlToValidate="txtUsername"
                            runat="server" />
                    </td>
                </tr>
                <tr>
                    <td>Password :
                    </td>
                    <td>
                        <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" />
                    </td>
                    <td>
                        <asp:RequiredFieldValidator ErrorMessage="Required" ForeColor="Red" ControlToValidate="txtPassword"
                            runat="server" />
                    </td>
                </tr>
                <tr>
                    <td>Confirm Password :
                    </td>
                    <td>
                        <asp:TextBox ID="txtConfirmPassword" runat="server" TextMode="Password" />
                    </td>
                    <td>
                        <asp:CompareValidator ErrorMessage="Passwords do not match." ForeColor="Red" ControlToCompare="txtPassword"
                            ControlToValidate="txtConfirmPassword" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td>Email :
                    </td>
                    <td>
                        <asp:TextBox ID="txtEmail" runat="server" />
                    </td>
                    <td>
                        <asp:RequiredFieldValidator ErrorMessage="Required" Display="Dynamic" ForeColor="Red"
                            ControlToValidate="txtEmail" runat="server" />
                        <asp:RegularExpressionValidator runat="server" Display="Dynamic" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                            ControlToValidate="txtEmail" ForeColor="Red" ErrorMessage="Invalid email address." />
                    </td>
                </tr>
                <tr>
                    <td>City :</td>
                    <td>
                        <asp:DropDownList ID="DropDownList1" runat="server">
                            <asp:ListItem>Ksa</asp:ListItem>
                            <asp:ListItem>USA</asp:ListItem>
                            <asp:ListItem>UAE</asp:ListItem>
                            <asp:ListItem>Lebanon</asp:ListItem>
                            <asp:ListItem>sirya</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>Gender :</td>
                    <td>
                        <asp:RadioButtonList ID="RadioButtonList1" runat="server">
                            <asp:ListItem>Male</asp:ListItem>
                            <asp:ListItem>Female</asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <asp:Button Text="Submit" runat="server" />
                    </td>
                    <td></td>
                </tr>
            </table>
        </div>

        <br />
        <%-- form 3--%>
        <div id="form3" class="form-inline ignoreClass">
            <div class="form-group">
                <label for="exampleInputName2">Name</label>
                <input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
            </div>
            <div class="form-group">
                <label for="exampleInputEmail2">Email</label>
                <input type="email" class="form-control" id="exampleInputEmail2" placeholder="jane.doe@example.com">
            </div>
            <%--<button type="submit" class="btn btn-default">Send invitation</button>--%>
            <asp:Button Text="Submit" runat="server" />
        </div>
        <br />
    </form>
请有关如何仅将dirtyform应用于ID为#form3的div的任何帮助

4

0 回答 0