From 3964acbdc82491083b6cc66eef8f95ebd362880b Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Sun, 14 Mar 2021 11:44:42 +0000 Subject: [PATCH] [Contesting] Adds Validation to the serial input fields This commit adds validation to the input fields, so that serial can only be a number and other can be freeform text. Co-Authored-By: m0pcb <60575997+m0pcb@users.noreply.github.com> --- assets/js/sections/contesting.js | 42 +++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/assets/js/sections/contesting.js b/assets/js/sections/contesting.js index 60e82efc0..cf1b60905 100644 --- a/assets/js/sections/contesting.js +++ b/assets/js/sections/contesting.js @@ -7,6 +7,14 @@ $("#exch_sent").val(1); $( document ).ready(function() { restoreContestSession(); setRst($("#mode").val()); + + // Check to see what serial type is selected and set validation + if($('#serial').is(':checked')) { + set_serial_number_input_validation(); + } + if($('#other').is(':checked')) { + set_other_input_validation(); + } }); // This erases the contest logging session which is stored in localStorage @@ -169,4 +177,36 @@ $('#band').change(function() { $('#frequency').val(result); $('#frequency_rx').val(""); }); -}); \ No newline at end of file +}); + +// Change Serial Validation when selected +$('#serial').change(function() { + if($('#serial').is(':checked')) { + set_serial_number_input_validation(); + } +}); + +// Change other serial type when selected +$('#other').change(function() { + if($('#other').is(':checked')) { + set_other_input_validation(); + } +}); + +/* + Function: set_serial_number_input_validation + Job: This sets the field input to number for validation +*/ +function set_serial_number_input_validation() { + $('#exch_sent').attr('type', 'number'); + $('#exch_recv').attr('type', 'number'); +} + +/* + Function: set_other_input_validation + Job: This sets the field input to text for validation +*/ +function set_other_input_validation() { + $('#exch_sent').attr('type', 'text'); + $('#exch_recv').attr('type', 'text'); +} \ No newline at end of file