From 9309634c50764314f89d014ef9ab7b39d2f47485 Mon Sep 17 00:00:00 2001 From: lyt Date: Thu, 19 Sep 2019 15:11:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20inquiry=20=E8=A1=A8=E5=8D=95=20JS=20+?= =?UTF-8?q?=20=E6=95=B0=E5=AD=97input=E7=9A=84plus/minus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/inquiry.form.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/js/inquiry.form.js b/js/inquiry.form.js index 13c98e0..b33d424 100644 --- a/js/inquiry.form.js +++ b/js/inquiry.form.js @@ -5,6 +5,32 @@ $(function() { }); } + $("a[minus]").each(function(index, element) { + $(element).click(function() { + var targetId = $(this).data("target"); + var $targetInput = $("#" + targetId); + var minVal = $targetInput.data("min"); + var inputVal = parseInt($targetInput.val()); + if (inputVal > minVal) { + inputVal -= 1; + $targetInput.val(inputVal); + } + }); + }); + + $("a[plus]").each(function(index, element) { + $(element).click(function() { + var targetId = $(this).data("target"); + var $targetInput = $("#" + targetId); + var maxVal = $targetInput.data("max"); + var inputVal = parseInt($targetInput.val()); + if (inputVal < maxVal) { + inputVal += 1; + $targetInput.val(inputVal); + } + }); + }); + $("#adult_number").combobox({ maxLength: 3, source: [{