fixing health form validation
This commit is contained in:
parent
ff2d64dd48
commit
966a6ddb67
2 changed files with 159 additions and 151 deletions
|
@ -11,14 +11,64 @@
|
|||
const age = calculate_age(birthdate);
|
||||
data.append("age", age);
|
||||
|
||||
if (data.get("tetanus-shot") === "") {
|
||||
console.warn("NO DATE FOR TETANUS SHOT");
|
||||
data.set("tetanus-shot", "0000-00-00");
|
||||
console.log(data.get("tetanus-shot"));
|
||||
}
|
||||
|
||||
if (document.getElementById("medical-coverage").checked && data.get("insurance-name") == "") {
|
||||
document.getElementById('warning-insurance').style.visibility = 'visible';
|
||||
document.getElementById('warning-insurance').style.height = '';
|
||||
document.getElementById('warning-insurance').style.margin = '';
|
||||
return false;
|
||||
} else {
|
||||
document.getElementById('warning-insurance').style.visibility = 'hidden';
|
||||
document.getElementById('warning-insurance').style.height = '0';
|
||||
document.getElementById('warning-insurance').style.margin = '0';
|
||||
}
|
||||
|
||||
if (document.getElementById("medical-coverage").checked && data.get("policy-number") == "") {
|
||||
document.getElementById('warning-policy').style.visibility = 'visible';
|
||||
document.getElementById('warning-policy').style.height = '';
|
||||
document.getElementById('warning-policy').style.margin = '';
|
||||
return false;
|
||||
} else {
|
||||
document.getElementById('warning-policy').style.visibility = 'hidden';
|
||||
document.getElementById('warning-policy').style.height = '0';
|
||||
document.getElementById('warning-policy').style.margin = '0';
|
||||
}
|
||||
|
||||
if (document.getElementById("medical-coverage").checked && document.getElementById("image").files.length === 0) {
|
||||
document.getElementById('warning-image').style.visibility = 'visible';
|
||||
document.getElementById('warning-image').style.height = '';
|
||||
document.getElementById('warning-image').style.margin = '';
|
||||
return false;
|
||||
} else {
|
||||
console.warn(document.getElementById("image"));
|
||||
document.getElementById('warning-image').style.visibility = 'hidden';
|
||||
document.getElementById('warning-image').style.height = '0';
|
||||
document.getElementById('warning-image').style.margin = '0';
|
||||
}
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = (e) => {
|
||||
if (xhr.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status === 200) {
|
||||
console.log('SUCCESS', xhr.responseText);
|
||||
} else {
|
||||
console.warn('request_error', xhr.responseText);
|
||||
}
|
||||
};
|
||||
xhr.open("POST", "https://n8n.tfcconnection.org/webhook/health-form");
|
||||
xhr.send(data);
|
||||
console.log(data);
|
||||
console.log("Hallo!");
|
||||
window.location.href = "https://tfcconnection.org/thankyou/";
|
||||
window.location.replace("https://tfcconnection.org/thankyou/");
|
||||
return false;
|
||||
/* window.location.href = "/thankyou/"; */
|
||||
/* window.location.replace("https://tfcconnection.org/thankyou/"); */
|
||||
}
|
||||
|
||||
function calculate_age(dob) {
|
||||
|
@ -41,9 +91,21 @@
|
|||
console.log(document.getElementById('policy'))
|
||||
console.log("NEGATORY");
|
||||
}
|
||||
document.getElementById('warning').style.visibility = 'hidden';
|
||||
document.getElementById('warning-insurance').style.visibility = 'hidden';
|
||||
document.getElementById('warning-policy').style.visibility = 'hidden';
|
||||
document.getElementById('warning-image').style.visibility = 'hidden';
|
||||
document.getElementById('warning').style.height = '0';
|
||||
document.getElementById('warning-insurance').style.height = '0';
|
||||
document.getElementById('warning-policy').style.height = '0';
|
||||
document.getElementById('warning-image').style.height = '0';
|
||||
document.getElementById('warning').style.margin = '0';
|
||||
document.getElementById('warning-insurance').style.margin = '0';
|
||||
document.getElementById('warning-policy').style.margin = '0';
|
||||
document.getElementById('warning-image').style.margin = '0';
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', process);
|
||||
document.addEventListener('DOMContentLoaded', process);
|
||||
|
||||
function dated() {
|
||||
function nth(d) {
|
||||
|
@ -78,26 +140,26 @@
|
|||
<div class="basis-full flex flex-wrap my-4">
|
||||
<label for="firstname" class="basis-full">What is your first and last name?</label>
|
||||
<br/>
|
||||
<input type="text" id="firstname" name="firstname"
|
||||
<input type="text" id="firstname" name="firstname" required
|
||||
placeholder="First Name" class="flex-1 form-input {{ $formClasses }}">
|
||||
<input type="text" id="lastname" name="lastname"
|
||||
<input type="text" id="lastname" name="lastname" required
|
||||
placeholder="Last Name" class="flex-1 form-input {{ $formClasses }}">
|
||||
</div>
|
||||
<div class="basis-full my-8">
|
||||
<div class="">
|
||||
<label for="birthdate" class="">When were you born?</label>
|
||||
<input type="date" id="birthdate" name="birthdate"
|
||||
class="form-date {{ $formClasses }}">
|
||||
class="form-date {{ $formClasses }}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="basis-full flex flex-wrap my-4">
|
||||
<label for="parentfirstname" class="basis-full">What is your parent's first and last name?</label>
|
||||
<input type="text" id="parentfirstname" name="parentfirstname"
|
||||
class="flex-1 form-input {{ $formClasses }}"
|
||||
placeholder="First Name">
|
||||
placeholder="First Name" required>
|
||||
<input type="text" id="parentlastname" name="parentlastname"
|
||||
class="flex-1 form-input {{ $formClasses }}"
|
||||
placeholder="Last Name">
|
||||
placeholder="Last Name" required>
|
||||
</div>
|
||||
<div class="basis-full flex flex-wrap my-4">
|
||||
<label for="street" class="basis-full">What is your address?</label>
|
||||
|
@ -116,7 +178,7 @@
|
|||
</div>
|
||||
<div class="basis-full flex flex-wrap items-center my-8">
|
||||
<div class="flex-auto flex flex-wrap items-center">
|
||||
<label for="cellphone" class="mr-4">Cell phone</label>
|
||||
<label for="cellphone" class="mr-4">Parent Cell phone</label>
|
||||
<input type="tel" id="cellphone" name="cellphone"
|
||||
pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"
|
||||
class="flex-auto form-input {{ $formClasses }}">
|
||||
|
@ -332,5 +394,34 @@
|
|||
<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>
|
||||
</div>
|
||||
|
||||
<div id="warning" 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 uploaded a copy of your insurance card.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="warning-insurance" 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") }}
|
||||
You have not entered in your insurance name.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="warning-policy" 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") }}
|
||||
You have not entered in a policy number.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="warning-image" 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") }}
|
||||
You have not included a copy of your insurance card.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue