From caba37eca639d64ba9a0e70a01fec7b7d228be0b Mon Sep 17 00:00:00 2001 From: Sanskruti Kolgane <96910867+Sansgithub22@users.noreply.github.com> Date: Thu, 13 Jul 2023 21:26:21 +0530 Subject: [PATCH 1/5] Task done!!! --- index.html | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 00000000..0f06a09c --- /dev/null +++ b/index.html @@ -0,0 +1,116 @@ + + + + + + + Registration Form + + + + +
+
+
+
+
+
+
+
+ +

Registration

+ +
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ + + + +
+
+ +

Branch

+
+ +
+ +
+ + +
+
+ +
+ +
+ +
+ +
+
+ + Sample image + +
+
+
+
+
+
+
+
+ + + + + + + + + From 5aef6df849a245745c911faed492b19b6f47bf17 Mon Sep 17 00:00:00 2001 From: Sanskruti Kolgane <96910867+Sansgithub22@users.noreply.github.com> Date: Thu, 13 Jul 2023 21:27:44 +0530 Subject: [PATCH 2/5] Task done!!! --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 0f06a09c..1bff9465 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,7 @@
-

Registration

+

Registration Form

From b59b0d9b856caac1c8285c3a3efe4b57ef6ca66c Mon Sep 17 00:00:00 2001 From: Sanskruti Kolgane <96910867+Sansgithub22@users.noreply.github.com> Date: Thu, 13 Jul 2023 21:30:03 +0530 Subject: [PATCH 3/5] Task done!!! --- script.js | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 script.js diff --git a/script.js b/script.js new file mode 100644 index 00000000..452b82a7 --- /dev/null +++ b/script.js @@ -0,0 +1,66 @@ +const firebaseConfig = { + apiKey: "AIzaSyD-1YUBnqzCmeSveTC_qEqZRYlWYeQUS5E", + authDomain: "regform-46ab8.firebaseapp.com", + databaseURL: "https://regform-46ab8-default-rtdb.firebaseio.com", + projectId: "regform-46ab8", + storageBucket: "regform-46ab8.appspot.com", + messagingSenderId: "125959196911", + appId: "1:125959196911:web:75162fabdf45f988a94b1a" +}; + +firebase.initializeApp(firebaseConfig); + +var contactFormDB = firebase.database().ref("regForm"); + +document.getElementById("contactForm").addEventListener("submit", submitForm); +function validateInputs(name, email, branch, phone) { + + var nameRegex = /^[a-zA-Z]+$/; + if (!nameRegex.test(name)) { + alert("Wrong Name Input | Registration Failed"); + return false; + } + var emailRegex = /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/; + if (!emailRegex.test(email)) { + alert("Wrong Email Input | Registration Failed"); + return false; + } + var phoneRegex = /^\d{10}$/; + if (!phoneRegex.test(phone)) { + alert("Wrong Phone Input | Registration Failed"); + return false; + } + return true; +} +function submitForm(e) { + e.preventDefault(); + + var name = getElementVal("name"); + var emailid = getElementVal("emailid"); + var branch = getElementVal("branch"); + var phone = getElementVal("phone"); + + var check = validateInputs(name, emailid, branch, phone); + if (check) { + saveMessages(name, emailid, branch, phone); + alert("Registration Successful"); + } + + document.getElementById("contactForm").reset(); +} + +const saveMessages = (name, emailid, branch, phone) => { + var newContactForm = contactFormDB.push(); + + newContactForm.set({ + name: name, + emailid: emailid, + branch: branch, + phone: phone, + }); +}; + +const getElementVal = (id) => { + return document.getElementById(id).value; +}; + From 59b321907345402aa9c47118725d57ad2a539d8c Mon Sep 17 00:00:00 2001 From: Sanskruti Kolgane <96910867+Sansgithub22@users.noreply.github.com> Date: Fri, 14 Jul 2023 08:45:54 +0530 Subject: [PATCH 4/5] Task Updated!!! --- index.html | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 1bff9465..d1b8dfb6 100644 --- a/index.html +++ b/index.html @@ -21,7 +21,7 @@

Registration Form

- +
@@ -41,7 +41,6 @@
- - +
@@ -112,5 +111,3 @@ - - From 06010e2d34c67a70bb850d550e359ad2feed35fe Mon Sep 17 00:00:00 2001 From: Sanskruti Kolgane <96910867+Sansgithub22@users.noreply.github.com> Date: Fri, 14 Jul 2023 08:46:49 +0530 Subject: [PATCH 5/5] Task Updated!!! --- script.js | 99 +++++++++++++++++++++++++++---------------------------- 1 file changed, 48 insertions(+), 51 deletions(-) diff --git a/script.js b/script.js index 452b82a7..6797acf6 100644 --- a/script.js +++ b/script.js @@ -1,66 +1,63 @@ const firebaseConfig = { - apiKey: "AIzaSyD-1YUBnqzCmeSveTC_qEqZRYlWYeQUS5E", - authDomain: "regform-46ab8.firebaseapp.com", - databaseURL: "https://regform-46ab8-default-rtdb.firebaseio.com", - projectId: "regform-46ab8", - storageBucket: "regform-46ab8.appspot.com", - messagingSenderId: "125959196911", - appId: "1:125959196911:web:75162fabdf45f988a94b1a" -}; + apiKey: "AIzaSyA0hA2Bc74PEzeuoahNApERIEkxFqv_jSo", + authDomain: "techteamexpansion23.firebaseapp.com", + projectId: "techteamexpansion23", + storageBucket: "techteamexpansion23.appspot.com", + messagingSenderId: "542718392377", + appId: "1:542718392377:web:bf6178e1b28494fe8c35e8", + measurementId: "G-39B1R2EWV2" + }; -firebase.initializeApp(firebaseConfig); -var contactFormDB = firebase.database().ref("regForm"); +firebase.initializeApp(firebaseConfig); +const db = firebase.firestore(); -document.getElementById("contactForm").addEventListener("submit", submitForm); +const collectionName = 'SANSKRUTI_CSE'; +document.getElementById("registrationForm").addEventListener("submit", submitForm); function validateInputs(name, email, branch, phone) { - - var nameRegex = /^[a-zA-Z]+$/; - if (!nameRegex.test(name)) { - alert("Wrong Name Input | Registration Failed"); - return false; - } - var emailRegex = /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/; - if (!emailRegex.test(email)) { - alert("Wrong Email Input | Registration Failed"); - return false; - } - var phoneRegex = /^\d{10}$/; - if (!phoneRegex.test(phone)) { - alert("Wrong Phone Input | Registration Failed"); - return false; - } - return true; + // Validate name + var nameRegex = /^[a-zA-Z]+$/; + if (!nameRegex.test(name)) { + alert("Wrong Name Input | Registration Failed"); + return false; + } + var emailRegex = /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/; + if (!emailRegex.test(email)) { + alert("Wrong Email Input | Registration Failed"); + return false; + } + var phoneRegex = /^\d{10}$/; + if (!phoneRegex.test(phone)) { + alert("Wrong Phone Input | Registration Failed"); + return false; + } + return true; } function submitForm(e) { - e.preventDefault(); + e.preventDefault(); - var name = getElementVal("name"); - var emailid = getElementVal("emailid"); - var branch = getElementVal("branch"); - var phone = getElementVal("phone"); + var name = getElementVal("name"); + var emailid = getElementVal("emailid"); + var branch = getElementVal("branch"); + var phone = getElementVal("phone"); + const formData = { + name: name, + email: emailid, + branch: branch, + phone: phone + }; - var check = validateInputs(name, emailid, branch, phone); - if (check) { - saveMessages(name, emailid, branch, phone); - alert("Registration Successful"); - } + var check = validateInputs(name, emailid, branch, phone); + if (check) { - document.getElementById("contactForm").reset(); -} -const saveMessages = (name, emailid, branch, phone) => { - var newContactForm = contactFormDB.push(); + db.collection(collectionName).add(formData); + alert("Registration Successful"); + } - newContactForm.set({ - name: name, - emailid: emailid, - branch: branch, - phone: phone, - }); -}; + document.getElementById("registrationForm").reset(); +} const getElementVal = (id) => { - return document.getElementById(id).value; + return document.getElementById(id).value; }; -