add requirement to camp-form

These requirements are to ensure emails from parents are added to the camp-form
This commit is contained in:
Chris Cochrun 2023-03-30 13:24:05 -05:00
parent 08448cf6e5
commit a1aa4ca9bf

View file

@ -12,6 +12,17 @@
const age = calculate_age(birthdate); const age = calculate_age(birthdate);
data.append("age", age); data.append("age", age);
if (data.get("parentemail") == "") {
document.getElementById('warning-email').style.visibility = 'visible';
document.getElementById('warning-email').style.height = '';
document.getElementById('warning-email').style.margin = '';
return false;
} else {
document.getElementById('warning-email').style.visibility = 'hidden';
document.getElementById('warning-email').style.height = '0';
document.getElementById('warning-email').style.margin = '0';
}
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
@ -53,6 +64,9 @@
function process() { function process() {
/* document.getElementById('mt-form').hidden = false */ /* document.getElementById('mt-form').hidden = false */
document.getElementById('warning-email').style.visibility = 'hidden';
document.getElementById('warning-email').style.height = '0';
document.getElementById('warning-email').style.margin = '0';
} }
document.addEventListener('DOMContentLoaded', process); document.addEventListener('DOMContentLoaded', process);
</script> </script>
@ -143,10 +157,10 @@
<input type="tel" id="parentphone" name="parentphone" <input type="tel" id="parentphone" name="parentphone"
class="basis-full form-input {{ $formClasses }}"> class="basis-full form-input {{ $formClasses }}">
<label for="parentemail" class="basis-full">Guardian's Email</label> <label for="parentemail" class="basis-full">Guardian's Email <span class='inline-block text-[#f39] text-sm align-sub'>* required</span></label>
<input type="parentemail" id="parentemail" name="parentemail" <input type="parentemail" id="parentemail" name="parentemail"
pattern="^[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*@[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*$" pattern="^[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*@[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*$"
class="basis-full form-input {{ $formClasses }}"> class="basis-full form-input {{ $formClasses }}" required>
<label for="allergies" class="basis-full">Do you have any food allergies?</label> <label for="allergies" class="basis-full">Do you have any food allergies?</label>
<input type="text" id="allergies" name="allergies" <input type="text" id="allergies" name="allergies"
@ -224,5 +238,13 @@
<div class="basis-full mt-8"> <div class="basis-full mt-8">
<button type="submit" class="content-right rounded-lg bg-primary-700 h-12 w-24 focus:bg-primary-900 focus:ring focus:ring-primary-700 hover:bg-primary-900 float-right">Submit</button> <button type="submit" class="content-right rounded-lg bg-primary-700 h-12 w-24 focus:bg-primary-900 focus:ring focus:ring-primary-700 hover:bg-primary-900 float-right">Submit</button>
</div> </div>
<div id="warning-email" class="basis-full mt-10 flex px-4 py-3 rounded-lg bg-[#ef4444] dark:bg-[#ef4444]">
<span class="text-[#fca5a5] ltr:pr-3 rtl:pl-3 content-right float-right">
{{ partial "icon.html" (.Get 0 | default "triangle-exclamation") }}
Make sure you have included an email for your guardian so we can contact them.
</span>
</div>
</form> </form>
</div> </div>