Uncaught TypeError: $ (...). Valid не является функцией в HTMLFormElement.dispatch (jquery -3.5.1.slim.min. js: 2) - PullRequest
0 голосов
/ 14 июля 2020

Привет, когда я нажимаю «Отправить» с пустыми полями, сообщения проверки отображаются нормально. Однако после заполнения всех полей появляется указанная выше ошибка. Если в нем отсутствуют библиотеки, то как он выполняется, когда все поля пусты. Это путаница, может кто-нибудь, пожалуйста, помогите мне, я не знаю, где я ошибаюсь.

$("#step1form").on('submit', function (e) {
        debugger
        e.preventDefault();
        if ($("#step1form").valid()) {
            var file = new FormData();
            file.append("InvoiceFile", file[0]);
            var objPrdVM = {
                PurchaseDate: $('.pickDate').val(),
                InvoiceNumber: $('#InvoiceNumber').val(),
                InvoiceFile: file,
                CategoryId: document.getElementById('CategoryName').selectedIndex,
                ProductId: document.getElementById('ProductId').selectedIndex,
                Quantity: $('#Quantity').val()
            }

            $.ajax({
                type: "POST",
                url: '/EnterRebateClaimStep1/EnterRebateClaimStep1',
                data: { objc: objPrdVM },
                success: funnn,
                error: ""
            });
        }

Это мои библиотеки, включенные в MainLayout.cs html файл

 <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet">
        <link href="~/Content/adminlte.css" rel="stylesheet" type="text/css" />
        <link href="~/Content/main.css" rel="stylesheet" type="text/css" />
        <link href="~/Plugins/fontawesome-free/css/all.min.css" rel="stylesheet" />
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.0.1/css/tempusdominus-bootstrap-4.min.css" />
        <link href="~/Plugins/daterangepicker/daterangepicker.css" rel="stylesheet" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
        <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
                integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
                crossorigin="anonymous"></script>
        <script src="~/Scripts/bootstrap.bundle.min.js"></script>
        <script src="~/Scripts/plugins/moment/moment.min.js"></script>
        <script src="~/Plugins/daterangepicker/daterangepicker.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.0.1/js/tempusdominus-bootstrap-4.min.js"></script>
        <script src="~/Scripts/jquery.validate.js"></script>
        <script src="~/Scripts/jquery.validate.unobtrusive.js"></script>

Это это мой cs html файл

@using (Html.BeginForm("EnterRebateClaimStep1", "EnterRebateClaimStep1", FormMethod.Post, new { id = "step1form", enctype = "multipart/form-data" }))
                        {
                            @Html.AntiForgeryToken()
                            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                            <!-- /.card-header -->
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-md-12">
                                        <h5 class="form_subhead"> Step 1: Enter Rebate Claim</h5>
                                        <hr />
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-md-4 mb-3">
                                        <div class="form-group">
                                            @Html.Label("Date")
                                            @Html.TextBox("dtprange", null, new { @class = "pickDate form-control" })
                                        </div>
                                    </div>
                                    <div class="col-md-4 mb-3">
                                        <div class="form-group">
                                            @Html.Label("Invoice Number")
                                            @Html.TextBoxFor(m => m.InvoiceNumber, new { @class = "form-control" })
                                            @Html.ValidationMessageFor(m => m.InvoiceNumber, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                    <div class="col-md-4 mb-3">
                                        <div class="form-group">
                                            @Html.Label("Upload Invoice")
                                            <div class="input-group">
                                                <div class="custom-file">
                                                    @Html.TextBoxFor(m => m.InvoiceFile, new { type = "file", @class = "custom-file-input", style = "cursor : pointer" })
                                                    @Html.Label("Choose File", new { @class = "custom-file-label" })
                                                    @*<input type="file" class="custom-file-input" id="exampleInputFile" style="cursor:pointer !important" required>
                                    <label class="custom-file-label" for="exampleInputFile">Choose file</label>*@
                                                </div>
                                            </div>
                                            @Html.ValidationMessageFor(m => m.InvoiceFile, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-md-4 mb-3">
                                        <div class="form-group">
                                            @Html.Label("Category")
                                            @if (categoriesdata != null)
                                            {
                                                @Html.DropDownList("CategoryName", new SelectList(categoriesdata, "Id", "CategoryName"), "Select Category", new { @class = "form-control custom-select", @onchange = "CategoryChange()" })
                                            }
                                            @Html.ValidationMessageFor(m => m.CategoryId, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                    <div class="col-md-4 mb-3">
                                        <div class="form-group">
                                            @Html.Label("Product")
                                            @Html.DropDownListFor(m => m.ProductId, new SelectList(""), "Select Product", new { @class = "form-control" })
                                            @Html.ValidationMessageFor(m => m.ProductId, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                    <div class="col-md-4 mb-3">
                                        <div class="form-group">
                                            @Html.Label("Quantity")
                                            @Html.EditorFor(model => model.Quantity, new { htmlAttributes = new { @class = "form-control", @type = "number", @min = "0", @step = "1", @value = "0" } })
                                            @Html.ValidationMessageFor(m => m.Quantity, "", new { @class = "text-danger" })
                                        </div>
                                    </div>
                                </div>

                                <div id="fdrain" style="display: none;">
                                    <div class="row clearfix">
                                        <div class="col-md-12 mb-3 clearfix">Did you also purchase F2 drain with this product?<span class="text-red">*</span></div>
                                    </div>
                                    <div class="row clearfix">
                                        <div class="col-md-2 mb-3">
                                            <div class="form-group">
                                                <div class="form-check">
                                                    @Html.RadioButtonFor(m => m.F2Drain, true)
                                                    @Html.Label("Yes")
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-2 mb-3">
                                            <div class="form-group">
                                                <div class="form-check">
                                                    @Html.RadioButtonFor(m => m.IsMultipleProductsSelected, false)
                                                    @Html.Label("No")
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row clearfix">
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-md-12 mb-3">Did you purchase another MAAX product that earns a rebate from this invoice?</div>
                                </div>
                                <div class="row">
                                    <div class="col-md-2 mb-3" style="margin-bottom:0px !important">
                                        <div class="form-group">
                                            <div class="form-check">
                                                @Html.RadioButtonFor(m => m.IsMultipleProductsSelected, true, new { @checked = "checked" })
                                                @Html.Label("Yes")
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-2 mb-3">
                                        <div class="form-group">
                                            <div class="form-check">
                                                @Html.RadioButtonFor(m => m.IsMultipleProductsSelected, false)
                                                @Html.Label("No")
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- /.card-body -->
                            <div class="row card-footer">
                                <input type="submit" class="btn btn-info" value="Next" id="step1Next" />

                                <button type="button" id="skip" class="btn btn-secondary ml-3" onclick="@Url.Action("InstallationInformation","InstallationInformation")" style="display: none">
                                    Skip
                                </button>
                            </div>
                            <!-- /.card-footer -->
                        }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...