From 65c7fb4c9105bbb8aeab2af626647a64878c3992 Mon Sep 17 00:00:00 2001 From: Simon Carr Date: Thu, 18 Oct 2018 21:42:26 +0100 Subject: [PATCH] Issue 716 - enable client side validation to prevent postback of text to quantity field, added small js function to restrict input to 0-9 keys only, make input classes consistant, correct inconsistent button styling, make datepickers more obvious --- .gitignore | 1 + .../Views/Organization/Home.cshtml | 26 ++++++++++++++----- .../Views/Shared/_Layout.cshtml | 1 + .../scripts/App/organizationHome.js | 8 +++++- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index d5ce2c57..45ec1df7 100644 --- a/.gitignore +++ b/.gitignore @@ -125,3 +125,4 @@ crisischeckin/CrisisCheckinMobile/Components/ *.sln.GhostDoc.xml project.lock.json crisischeckin/CrisisCheckinMobile/CrisisCheckInMobile.sln.DotSettings +/crisischeckin/UpgradeLog3.htm diff --git a/crisischeckin/crisicheckinweb/Views/Organization/Home.cshtml b/crisischeckin/crisicheckinweb/Views/Organization/Home.cshtml index cef0c263..c942c8a4 100644 --- a/crisischeckin/crisicheckinweb/Views/Organization/Home.cshtml +++ b/crisischeckin/crisicheckinweb/Views/Organization/Home.cshtml @@ -139,11 +139,25 @@ @Html.DropDownListFor(m => m.ResourceDisasterId, new SelectList(Model.AllDisasters, "Id", "Name", Model.ResourceDisasterId), "-- Choose One --", new { @class = "form-control", @id = "disasterList" }) - @Html.TextBoxFor(m => m.ResourceDescription) - @Html.TextBoxFor(m => m.ResourceQuantity) + @Html.TextBoxFor(m => m.ResourceDescription, new { @class = "form-control" }) + @Html.TextBoxFor(m => m.ResourceQuantity, new { @class = "form-control numeric-only" }) @Html.DropDownListFor(m => m.ResourceTypeId, new SelectList(Model.ResourceTypes, "ResourceTypeId", "TypeName", Model.ResourceTypeId), "-- Choose One --", new { @class = "form-control", @id = "resourcetypelist" }) - @Html.TextBoxFor(m => m.ResourceStartDate, new { id = "dp_resourceStartDate", @class = "form-control" }) - @Html.TextBoxFor(m => m.ResourceEndDate, new { id = "dp_resourceEndDate", @class = "form-control" }) + +
+ + + + @Html.TextBoxFor(m => m.ResourceStartDate, new { id = "dp_resourceStartDate", @class = "form-control"}) +
+ + +
+ + + + @Html.TextBoxFor(m => m.ResourceEndDate, new { id = "dp_resourceEndDate", @class = "form-control" }) +
+ @Html.TextBoxFor(m => m.ResourceLocation, new { @class = "form-control" }) @@ -195,7 +209,7 @@ @Html.AntiForgeryToken() @Html.HiddenFor(m => m.OrganizationId, new { @Value = Model.OrganizationId }) @Html.HiddenFor(m => m.PromoteToAdminPersonId, new { @Value = volunteer.Id }) - + } } else @@ -224,7 +238,7 @@ @Html.ValidationSummary() @Html.HiddenFor(m => m.OrganizationId, new { @Value = Model.OrganizationId }) @Html.DropDownListFor(m => m.AddVolunteerId, Model.VolunteersSelectList, "-- Select Volunteer --", new { @class = "form-control", @id = "addvolunteerlist" }) - + } } diff --git a/crisischeckin/crisicheckinweb/Views/Shared/_Layout.cshtml b/crisischeckin/crisicheckinweb/Views/Shared/_Layout.cshtml index 403a0efa..bde79e02 100644 --- a/crisischeckin/crisicheckinweb/Views/Shared/_Layout.cshtml +++ b/crisischeckin/crisicheckinweb/Views/Shared/_Layout.cshtml @@ -44,6 +44,7 @@ @Scripts.Render("~/bundles/libs") + @Scripts.Render("~/bundles/jquery-validate") @RenderSection("scripts", false) \ No newline at end of file diff --git a/crisischeckin/crisicheckinweb/scripts/App/organizationHome.js b/crisischeckin/crisicheckinweb/scripts/App/organizationHome.js index 58d0f3ad..e04c6381 100644 --- a/crisischeckin/crisicheckinweb/scripts/App/organizationHome.js +++ b/crisischeckin/crisicheckinweb/scripts/App/organizationHome.js @@ -1,9 +1,15 @@ -(function ($) {$(document).ready(function () { +(function ($) { + $(document).ready(function () { $("#dp_resourceStartDate").datepicker({ minDate: 'today', onSelect: updateResourceEndDate }).datepicker('setDate', '@(Model.ResourceStartDate == default(DateTime) ? DateTime.Now : Model.ResourceStartDate)'); $("#dp_resourceEndDate").datepicker({ minDate: 'today' }).datepicker('setDate', '@(Model.ResourceEndDate == default(DateTime) ? DateTime.Now : Model.ResourceEndDate)'); + $('.numeric-only').on('input blur paste', + function () { + $(this).val($(this).val().replace(/\D/g, '')); + }); + }); function updateResourceEndDate(dateText) {