Improve paper_id handling in register form
Change-Id: Ia5b5d61cbe9044f84ce6e3932b0538ae0708a52c
diff --git a/static/main.js b/static/main.js
index ee19a8a..eed544b 100644
--- a/static/main.js
+++ b/static/main.js
@@ -16,12 +16,14 @@
event.stopPropagation();
}
update_total_due();
+ update_paper_id_field();
form.classList.add('was-validated');
}, false);
});
}, false);
window.addEventListener('popstate', function(event) {
update_total_due();
+ update_paper_id_field();
}, false);
})();
@@ -60,10 +62,10 @@
var paper_id = $("#paper_id");
if ($('#author').is(":checked")) {
paper_id.removeAttr('disabled');
- paper_id.attr('pattern', '\\d{1,4}');
+ paper_id.attr('pattern', '[1-9]\\d{0,3}');
paper_id.attr('required', 'required');
val = paper_id.val();
- if (!x.match(/^\d{1,4}$/)) {
+ if (!val.match(/^\d{1,4}$/)) {
paper_id.val('');
}
} else {
diff --git a/templates/register.htm b/templates/register.htm
index 3030101..200d46c 100644
--- a/templates/register.htm
+++ b/templates/register.htm
@@ -463,8 +463,8 @@
<div class="form-outline col-md-5">
<label class="form-label fw-bold" for="paper_id">Paper ID</label>
- <input type="text" class="form-control fs-4" name="accepted_paper_id" id="paper_id" <?php echo isset($_POST[ 'author']) ? 'placeholder="0"' : 'disabled' ?> value="
- <?php echo isset($_POST['paper_id']) ? htmlspecialchars($_POST['paper_id']) : '' ?>" />
+ <input type="text" class="form-control fs-4" name="accepted_paper_id" id="paper_id" <?php echo isset($_POST[ 'author']) ? 'placeholder="0" required' : 'disabled' ?>
+ <?php echo isset($_POST['accepted_paper_id']) ? 'value="'.htmlspecialchars($_POST['accepted_paper_id']) . '"' : '' ?> />
<div class="invalid-feedback">
Please provide the ID number of your accepted paper.
</div>