Вот моя страница, на которой я хочу проверить, является действительной формой или нет от функции jQuery .. Код выглядит следующим образом: < /p>
@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;
}
}
}
< /code>
Это моя модель: < /p>
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();
}
}
< /code>
Здесь, когда я отлаживаю код скрипта в браузере, он дал «uncaught typeerror: $ (...). Действительно не является функцией». Эта ошибка на функции value (). Как может решить эту проблему? заранее спасибо ...
Подробнее здесь: https://stackoverflow.com/questions/377 ... ing-form-v
Ошибка: uncaught typeerror: $ (...). Действительно не является функцией при использовании ('#form'). Valive () ⇐ Jquery
Программирование на jquery
1743545170
Anonymous
Вот моя страница, на которой я хочу проверить, является действительной формой или нет от функции jQuery .. Код выглядит следующим образом: < /p>
@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;
}
}
}
< /code>
Это моя модель: < /p>
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();
}
}
< /code>
Здесь, когда я отлаживаю код скрипта в браузере, он дал «uncaught typeerror: $ (...). Действительно не является функцией». Эта ошибка на функции value (). Как может решить эту проблему? заранее спасибо ...
Подробнее здесь: [url]https://stackoverflow.com/questions/37701545/erroruncaught-typeerror-valid-is-not-a-function-while-using-form-v[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия