@model ClienteManagment.ViewModels.IntakeFormViewModel
@{
ViewBag.Title = "IntakeForm";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
<h2>Intake Form</h2>
<form id="newIntake">
<div class="form-group">
@Html.LabelFor(m => m.Intake.ItemName)
@Html.TextBoxFor(m => m.Intake.ItemName, new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.Intake.ItemName)
</div>
<div class="form-group">
@Html.LabelFor(m => m.Intake.ItemDescription)
@Html.TextBoxFor(m => m.Intake.ItemDescription, new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.Intake.ItemDescription)
</div>
<div class="form-group">
@Html.LabelFor(m => m.Intake.Segment)
@Html.DropDownListFor(m => m.Intake.SegmentId, new SelectList(Model.Segment, "Id", "Name"), "Select Segment", new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.Intake.SegmentId)
</div>
<div class="form-group">
@Html.LabelFor(m => m.Intake.MarketingLead)
@Html.DropDownListFor(m => m.Intake.MarketingLeadId, new SelectList(Model.MarketingLead, "Id", "Name"), "Select Marketing Lead", new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.Intake.MarketingLead)
</div>
<div class="form-group">
@Html.Label("Intake Type")
<br />
<div class="radio">
@{
foreach (var row in Model.IntakeType)
{
@Html.RadioButtonFor(m => m.Intake.IntakeTypeId, row.Id)
@Html.Label(row.Name)
<br />
}
}
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.Intake.Quantity)
@Html.TextBoxFor(m => m.Intake.Quantity, new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.Intake.Quantity)
</div>
<button class="btn btn-primary">Submit</button>
</form>
@section scripts
{
@Scripts.Render("~/bundles/jqueryval")
<script>
$(document).ready(function () {
var validator = $("#newIntake").validate({
submitHandler: function () {
console.log("Handling Submit!");
var dateSub = new Date().toLocaleString();
var formData = {
"ItemName": $("#Intake_ItemName").val(),
"ItemDescription": $("#Intake_ItemDescription").val(),
"IntakeTypeId": $("#Intake_IntakeTypeId").val(),
"SegmentId": $("#Intake_SegmentId").val(),
"MarketingLeadID": $("#Intake_MarketingLeadId").val(),
"Quantity": $("#Intake_Quantity").val(),
"DateSubmitted": dateSub
};
$.ajax({
url: "/api/intake",
method: "post",
data: formData
})
.done(function () {
console.log("Yeah! It worked.");
// Clear the form
//$("#newIntake").get(0).reset()
//validator.resetForm();
})
.fail(function () {
console.log("Something unexpected happened.");
});
return false;
}
});
});
</script>
}
ASKER
ASKER
@section scripts
{
@Scripts.Render("~/bundles/jqueryval")
<script>
// MOVED CODE OUTSIDE $(document).ready
$(document).ready(function () {
// CODE USED TO BE HERE
});
// NOW CODE IS HERE...
var validator = $("#newIntake").validate({
submitHandler: function () {
console.log("Handling Submit!");
var dateSub = new Date().toLocaleString();
var formData = {
"ItemName": $("#Intake_ItemName").val(),
"ItemDescription": $("#Intake_ItemDescription").val(),
"IntakeTypeId": $("#Intake_IntakeTypeId").val(),
"SegmentId": $("#Intake_SegmentId").val(),
"MarketingLeadID": $("#Intake_MarketingLeadId").val(),
"Quantity": $("#Intake_Quantity").val(),
"DateSubmitted": dateSub
};
$.ajax({
url: "/api/intake",
method: "post",
data: formData
})
.done(function () {
console.log("Yeah! It worked.");
// Clear the form
validator.resetForm();
})
.fail(function () {
console.log("Something unexpected happened.");
});
return false;
}
});
</script>
}
ASKER
ASKER
ASKER
ASKER
ASKER
@section scripts
{
@Scripts.Render("~/bundles/jqueryval")
<script>
$(document).ready(function () {
var validator = $("#newIntake").validate({
submitHandler: function () {
console.log("Handling Submit!");
var dateSub = new Date().toLocaleString();
var formData = {
"ItemName": $("#Intake_ItemName").val(),
"ItemDescription": $("#Intake_ItemDescription").val(),
"IntakeTypeId": $("#Intake_IntakeTypeId").val(),
"SegmentId": $("#Intake_SegmentId").val(),
"MarketingLeadID": $("#Intake_MarketingLeadId").val(),
"Quantity": $("#Intake_Quantity").val(),
"DateSubmitted": dateSub
};
alert("reached");
$.ajax({
url: "/api/intake",
method: "post",
data: formData
})
.done(function () {
console.log("Yeah! It worked.");
// Clear the form
validator.resetForm();
})
.fail(function () {
console.log("Something unexpected happened.");
});
return false;
}
});
});
</script>
}
ASKER
ASKER
The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications
TRUSTED BY
Open in new window