Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions templates/judge.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,29 @@
return new Date(secs * 1000).toLocaleTimeString();
}

function validateInputs() {
var error = false;

$(this).closest("form").find(".input-required").each(function () {
if ($.trim(this.value) === "") {
error = true;
}
});

$(this).closest("form").find(".radio-required").each(function () {
if ($("input:radio:checked", this).length < 1) {
error = true;
}
});

if (error) {
$(this).closest("form").find("button:submit").attr("disabled", "disabled");
}
else {
$(this).closest("form").find("button:submit").removeAttr("disabled");
}
}

function postForm(e) {
e.preventDefault(); // Prevent normal form submission

Expand Down Expand Up @@ -339,6 +362,10 @@
// Enable all Bootstrap popovers
$("[data-toggle='tooltip']").tooltip();

// Form input validation actions
$(".input-required").on("input", validateInputs);
$(".radio-required").on("input", validateInputs);

// Form submit actions
$(".form-ajax-submit").submit(postForm);
$(".form-no-submit").submit(function (e) {e.preventDefault();});
Expand Down Expand Up @@ -749,7 +776,7 @@ <h4 id="extraCommandResults"></h4>
Set flags to 0
</label>
</div>
<button type="submit" class="center-block btn btn-primary">
<button type="submit" class="center-block btn btn-primary" disabled>
Start Game
</button>
</div>
Expand Down Expand Up @@ -823,7 +850,7 @@ <h4 id="extraCommandResults"></h4>

<div class="col-sm-3 col-xs-12">
<div class="form-group">
<button type="submit" class="center-block btn btn-primary">
<button type="submit" class="center-block btn btn-primary" disabled>
Set Flags
</button>
</div>
Expand Down