From f5c89b9c19fce3e9d8adfd7202d8498812c59c42 Mon Sep 17 00:00:00 2001 From: "Max S. Haberman" Date: Tue, 15 Sep 2020 23:55:07 -0400 Subject: [PATCH] Added invalid result warning --- extrabuttons.fieldplugin.zip | Bin 5781 -> 5933 bytes source/manifest.json | 2 +- source/script.js | 24 ++++++++++++++++++++++-- source/style.css | 8 ++++++++ source/template.html | 4 +++- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/extrabuttons.fieldplugin.zip b/extrabuttons.fieldplugin.zip index 194405cd8723ea363893692cf60f8b111be37d57..f0ae8f396e144fcb13cb2c9b3875930ff84c879b 100644 GIT binary patch literal 5933 zcmc&&cQl;qw;l|GQARhqm?5GkTJ#bGqjyH{g6M+i5|L<8Mjb7>h%$ueEkqDKh$Iq3 ziyjgg!R7qUSx0hm*1Grpaql~8uld%RwchZ;a%o%7> zeFQ?;9i8j^$;C}L0eq_yw80Cn=9~KDpsKhYvc^@y$6Ntzbr7KqdwE>?DaJEm z+P|gz{PY+4Q_7Z>8uE%-dd33$mcM6z>y-Uj{KDSWipJK_%EoG217WyLZg@{S3^$P; zj|;+xvt!3bu#<2Zg3qL=5Rr#SjOUZ%y;mGXbcw&CgDo{Xw<670J2AODE!h~UYnq*z zlw_P#&IBPb2m;=NLg}Z$m%r@l>V;+RTc|9^QF>2BRfIb!o{|6&y1n(By?F}z4Eo=s zy3W1Fb|wIT=#-SVt(UXM*<1YM9U@QBd;b}~uy}6b<~=J)dHlo@hsPi8teP^5kVOuw z^~P*)O84zdw>9^}oIw}ZV?^+)flek<2kriJ0e=N9)n)H-0Q`fjmYX+t>Sq@WG%=yUbxzB?NU`Sw7me1zH$d9cNEVZs73>i z?$%t+LBST3ieB6+yim3jTXE2EKXrf+g}D}UnIy*g zszo;HwU@(>oFx;in$-Gka%#~NRKX` zH*HDB!*Td!&rTBnjEXYQFX02wcqS!P{#wWuB-ym)_yk#qz$i$)5Xh2Sgh(;`Sn%Gu36Yw|XAKVsr6qetm5o=#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2p2kWLzY1&H`?>FmP|LQ&@MJo#K2h#WVq{B-=+ZirPqYz=Ac1L)hO`Zj&P z7>+O3{&-h!znV|hb94-h%$T10pKz}pF<_U+BuFh$AR>if zrQm|$@^i{94v1H3&_MP&mczu}fi5S*W0X278N}Xl*NNCG3omGVW z4s@io(Y^h9M8kEbV3ic(#44_Uo;V{uEaw`2of%}BO-GMBG2n{2DEuPR&jm+CP}+Sz zc6SGcuy4)g`-5aYz;WihnkZD2AuX&Z5(!^@nGy2vt8)fE7?&eeYkx%VaUERbm79Ey z6Hlg>|2M0u?I~6%Sq&^i&5@I03mZ zR@7E=!E23`4-2LS)P!TndQ0d1N?%~ak zhvm@0R9Crw7en! diff --git a/source/manifest.json b/source/manifest.json index 67f563c..4b6369e 100644 --- a/source/manifest.json +++ b/source/manifest.json @@ -1,7 +1,7 @@ { "name" : "Extra buttons", "author" : "Dobility", - "version": "1.2.8", + "version": "2.0.1", "supportedFieldTypes": ["text", "integer", "decimal"], "hideDefaultRequiredMessage": true, "hideDefaultConstraintMessage": true diff --git a/source/script.js b/source/script.js index ecaed92..73db68d 100644 --- a/source/script.js +++ b/source/script.js @@ -6,28 +6,42 @@ var controlMessage = document.querySelector('.control-message') var formattedSpan = document.querySelector('#formatted') var buttonContainer = document.querySelector('#buttons') var warningContainer = document.querySelector('#warning') +var invalidBox = document.querySelector('.error-box') var fieldType = fieldProperties.FIELDTYPE var appearance = fieldProperties.APPEARANCE var altValues = [] var buttonsDisp = '' +var specialConstraint + +invalidBox.style.display = 'none' if (fieldType === 'integer') { input.inputmode = 'numeric' input.type = 'number' + specialConstraint = new RegExp('^-?[0-9]+$') + invalidBox.innerHTML = 'Invalid: Answer must be a valid integer.' } else if (fieldType === 'decimal') { input.inputmode = 'decimal' input.type = 'number' + specialConstraint = new RegExp('^-?([0-9]+.?[0-9]*)|([0-9]*.?[0-9]+)$') + invalidBox.innerHTML = 'Invalid: Answer must be a valid decimal number.' } else if (fieldType === 'text') { if (appearance.indexOf('numbers_phone') !== -1) { input.inputmode = 'tel' input.type = 'tel' + specialConstraint = new RegExp('^[0-9-+.#* ]+$') + invalidBox.innerHTML = 'Invalid: Answer can only contain numbers, hyphens (-), plus signs (+), dots (.), hash signs (#), asterisks (*), and/or spaces.' } else if (appearance.indexOf('numbers_decimal') !== -1) { input.inputmode = 'decimal' input.type = 'number' + specialConstraint = new RegExp('^-?([0-9]+.?[0-9]*)|([0-9]*.?[0-9]+)$') + invalidBox.innerHTML = 'Invalid: Answer must be a valid decimal number.' } else if (appearance.indexOf('numbers') !== -1) { input.inputmode = 'numeric' input.type = 'number' + specialConstraint = new RegExp('^[0-9-+. ]+$') + invalidBox.innerHTML = 'Invalid: Answer can only contain numbers, hyphens (-), plus signs (+), dots (.), and/or spaces.' } } @@ -115,8 +129,14 @@ input.oninput = function () { formattedSpan.innerHTML = total } } - setMetaData('') - setAnswer(currentAnswer) + + if ((currentAnswer === '') || specialConstraint.test(currentAnswer)) { + invalidBox.style.display = 'none' + setMetaData('') + setAnswer(currentAnswer) + } else { + invalidBox.style.display = '' + } } function buttonFontAdjuster (button) { // djusts size of the text of the buttons in case the text is too long diff --git a/source/style.css b/source/style.css index 9564a6d..56dd325 100644 --- a/source/style.css +++ b/source/style.css @@ -126,4 +126,12 @@ button.bluebutton{ .form-group.has-error .form-control { /*Input box when there is an error*/ border-color: #f56954!important; box-shadow: none; +} + +.error-box { + background: #f56954; + display: block; + width: 96%; + color: #FFF; + padding: 5px 10px; } \ No newline at end of file diff --git a/source/template.html b/source/template.html index 2fe4068..9b1a7d9 100644 --- a/source/template.html +++ b/source/template.html @@ -47,4 +47,6 @@
Warning: This field already has a value. Are you sure you would like to replace it?
-
\ No newline at end of file + + +
Invalid entry!
\ No newline at end of file