Ошибка: Uncaught TypeError: $(...).valid не является функцией при использовании ('#form').valid()Jquery

Программирование на jquery
Ответить Пред. темаСлед. тема
Anonymous
 Ошибка: Uncaught TypeError: $(...).valid не является функцией при использовании ('#form').valid()

Сообщение Anonymous »

Вот моя страница, на которой я хочу проверить корректность формы с помощью функции jquery. Код следующий:

Код: Выделить всё



@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "addNominationForm"}))
{
@Html.AntiForgeryToken()



@Html.ValidationSummary(true, "", new { @class = "text-danger" })


@Html.Label("Nomination Category", htmlAttributes: new { @class = "control-label col-md-3 requiredfeild", style = "text-align: left" })

@Html.DropDownListFor(model => model.AwardId, @ViewBag.Awards as SelectList, "Select", new { htmlAttributes = new { @class = "form-control" }, id = "Award", style = "width:25%" })



@Html.Label("Resource From", htmlAttributes: new { @class = "control-label col-md-3 requiredfeild", style = "text-align: left" })

 @Html.RadioButtonFor(model => model.SelectResourcesBy, "Project", new { htmlAttributes = new { @class = "form-control" }, id = "ProjectRadioButton" })Project
 
 @Html.RadioButtonFor(model => model.SelectResourcesBy, "Department", new { htmlAttributes = new { @class = "form-control" }, id = "DepartmentRadioButton" })Department





@Html.Label("Project", htmlAttributes: new { @class = "control-label col-md-3 requiredfeild", style = "text-align: left" })

@Html.DropDownListFor(model => model.ProjectID, @ViewBag.ProjectsUnderCurrentUser as SelectList, "Select", new { htmlAttributes = new { @class = "form-control" }, id = "SelectedProject", style = "width:25%" })



@Html.Label("Department", htmlAttributes: new { @class = "control-label col-md-3 requiredfeild", style = "text-align: left" })

@Html.DropDownListFor(model => model.DepartmentId, @ViewBag.DepartmentsUnderCurrentUser as SelectList, "Select", new { htmlAttributes = new { @class = "form-control" }, id = "SelectedDepartment", style = "width:25%" })



@Html.Label("Resource Name", htmlAttributes: new { @class = "control-label col-md-3 requiredfeild", style = "text-align: left" })

@Html.DropDownListFor(model => model.ResourceId, @ViewBag.Resources as SelectList, "Select", new { htmlAttributes = new { @class = "form-control" }, id = "Resources", style = "width:25%" })



@Html.Label("Is PLC ?", htmlAttributes: new { @class = "control-label col-md-3", style = "text-align: left" })

@Html.CheckBoxFor(model => model.IsPLC, new { htmlAttributes = new { @class = "form-control" }, id = "IsPlcCheckbox" }) Yes








@Html.ValidationMessageFor(model =>  model.Comments, "", new { @class = "text-danger" })



@Html.Label("Comment", htmlAttributes: new { @class = "control-label col-md-2 requiredfeild", style = "text-align: left" })

@Html.TextAreaFor(model => model.MainComment, new { htmlAttributes = new { @class = "form-control" }, id = "managerComment", style = "min-width: 80%", rows = "7", placeholder = "If candidate is selected as winner, this text will be shared across the company" })










}







function checkCriteriaComments() {
var comments = 0;

if($("#addNominationForm").valid())
{
alert("valid form");
}

$(".criteriaComment").children("textarea").each(function (data) {
if ($(this).val().trim())
comments++;
});

if (!$("#Award").val()) {
$("#Award").tooltip({ title: "Select Award.", placement: 'right' }).tooltip('show');
return false;
}

else if (comments < 1) {
$(".criteriaComment").children("textarea").first().tooltip({ title: "Enter at least one criteria comment.", placement: 'right' }).tooltip('show');
return false;
}
else if (!$("#managerComment").val()) {
$("#managerComment").tooltip({ title: "Enter main comment.", placement: 'right' }).tooltip('show');
return false;
}
else {
swal({
title: "Add Nomination",
text: "Do you want to nominate this candidate?",
type: "info",
showCancelButton: true,
confirmButtonColor: "#88a364",
confirmButtonText: "Yes!",
cancelButtonText: "No!",
closeOnConfirm: false,
closeOnCancel: false
},
function (isConfirm) {
if (isConfirm) {
debugger;
var model = $('#addNominationForm').serialize()

$.ajax({
type: 'post',
url: '@Url.Action("AddNomination", "Nomination")',
data: JSON.stringify({ model: model,submit:"Submit" }),
contentType: "application/json;  charset=utf-8",
success: function (data) {
swal({
title: "Nominated Successfully",
showCancelButton: false,
confirmButtonColor: "#88a364",
confirmButtonText: "Ok"
},
function () {
if (isConfirm) {
window.location.href = '@Url.Action("Dashboard", "Dashboard")';
}
});
}
});
} else {
swal("Cancelled", "Nomination Cancelled");
}
});

return true;
}

}
}


Это моя модель:

Код: Выделить всё

  public class NominationViewModel
{
[Required(ErrorMessage = "Select Award")]
public int AwardId { get; set; }

public int NominationId { get; set; }
public int ManagerId { get; set; }

[Required(ErrorMessage = "Select Resource")]
public int ResourceId { get; set; }

[Required(ErrorMessage = "Select Project")]
public int? ProjectID { get; set; }

[Required(ErrorMessage = "Select Department")]
public int? DepartmentId { get; set; }
public bool IsPLC { get; set; }
public bool? IsSubmitted { get; set; }

public string MainComment { get; set; }

[Required(ErrorMessage = "Select Project or Department")]
public string SelectResourcesBy { get; set; }  //from project or from department

[Required(ErrorMessage = "Please provide comment against criteria")]
public IList Comments { get; set; }

public NominationViewModel()
{
Comments = new List();
}

}
Здесь, когда я отлаживаю код сценария в браузере, он выдает «Uncaught TypeError: $(...).valid is not a function» эту ошибку при valid() функция.. Как решить эту проблему? заранее спасибо...

Подробнее здесь: https://stackoverflow.com/questions/377 ... ing-form-v
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Ошибка: Uncaught TypeError: $(...).valid не является функцией при использовании ('#form').valid()
    Anonymous » » в форуме Jquery
    0 Ответы
    22 Просмотры
    Последнее сообщение Anonymous
  • Ошибка: uncaught typeerror: $ (...). Действительно не является функцией при использовании ('#form'). Valive ()
    Anonymous » » в форуме Jquery
    0 Ответы
    34 Просмотры
    Последнее сообщение Anonymous
  • Страница перезагрузки плагина WordPress Form Form Form
    Anonymous » » в форуме Jquery
    0 Ответы
    38 Просмотры
    Последнее сообщение Anonymous
  • Страница перезагрузки плагина WordPress Form Form Form
    Anonymous » » в форуме Javascript
    0 Ответы
    41 Просмотры
    Последнее сообщение Anonymous
  • Страница перезагрузки плагина WordPress Form Form Form
    Anonymous » » в форуме Jquery
    0 Ответы
    26 Просмотры
    Последнее сообщение Anonymous

Вернуться в «Jquery»