From 1fcbf93fd7608a96cd35b28f265380d4bb412af6 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Wed, 8 Jul 2020 19:56:29 +0530 Subject: [PATCH] form validation --- index.html | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 3ad91a9..a0e2ce7 100644 --- a/index.html +++ b/index.html @@ -9424,7 +9424,7 @@ let mainObj = validateForm() if (mainObj != 0) { - floCloudAPI.sendGeneralData(JSON.stringify(mainObj), 'test3').then((result) => { + floCloudAPI.sendGeneralData(JSON.stringify(mainObj), 'test3').then((result, mainObj) => { if (result.split(":")[0].trim() == "Data sent to supernode") { //document.getElementById('directapply_resetform').click() @@ -9444,6 +9444,14 @@ } } + let projectlisttablebody = document.getElementById('projectlisttablebody') + // appending application to applicant list + projectlisttablebody.innerHTML = projectlisttablebody.innerHTML + + ` + ${myFloID} + ${aproject} + ` + } else { @@ -9460,7 +9468,7 @@ aname = document.getElementById('name').value aname = aname.replace(/\s+/g, ' ') aname = aname.trim() - if (aname == '' && aname.length < 2) { + if (aname == '' || aname.length < 2) { alert('You have entered an invalid name!') return 0 } @@ -9475,7 +9483,7 @@ acollege = document.getElementById('college').value acollege = acollege.replace(/\s+/g, ' ') acollege = acollege.trim() - if (acollege == '' && acollege.length < 2) { + if (acollege == '' || acollege.length < 2) { alert('You have entered an invalid college!') return 0 } @@ -9483,7 +9491,7 @@ acourse = document.getElementById('course').value acourse = acourse.replace(/\s+/g, ' ') acourse = acourse.trim() - if (acourse == '' && acourse.length < 2) { + if (acourse == '' || acourse.length < 2) { alert('You have entered an invalid course!') return 0 } @@ -9647,17 +9655,17 @@ ` } - if (applicantsIDarray.includes(myFloID)) { window.myFloID_isApplicant = true window.myFloID_Projects = [] + var tcounter = 0 for (let i = 0; i < applicants_InformationArray.length; i++) { if (myFloID == applicants_InformationArray[i]['sender']) { var temp = JSON.parse(applicants_InformationArray[i]['message']) myFloID_Projects.push(temp[myFloID]['project']) - + // force user to not change his details if he already exists - if (i == 0) { + if (tcounter == 0) { document.getElementById('name').value = temp[myFloID]['name'] document.getElementById('name').readOnly = true document.getElementById('email').value = temp[myFloID]['email'] @@ -9671,6 +9679,7 @@ document.getElementById('whatsapp').value = temp[myFloID]['whatsapp'] document.getElementById('whatsapp').readOnly = true document.getElementById('directapply_resetform').style.display = 'none' + tcounter = tcounter + 1 } } }