[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>
这个提交包含在:
Peter Goodhall 2021-03-14 11:44:42 +00:00
父节点 db80f8baf5
当前提交 3964acbdc8

查看文件

@ -7,6 +7,14 @@ $("#exch_sent").val(1);
$( document ).ready(function() { $( document ).ready(function() {
restoreContestSession(); restoreContestSession();
setRst($("#mode").val()); 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 // This erases the contest logging session which is stored in localStorage
@ -169,4 +177,36 @@ $('#band').change(function() {
$('#frequency').val(result); $('#frequency').val(result);
$('#frequency_rx').val(""); $('#frequency_rx').val("");
}); });
}); });
// 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');
}