Skip to content

Commit 6e5d650

Browse files
committed
Fix form errors. Update README
1 parent 31761a7 commit 6e5d650

File tree

2 files changed

+70
-54
lines changed

2 files changed

+70
-54
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# RocPy Website
2+
3+
This is the website for the Rochester Python "RocPy" Meetup, a Python user group in Rochester, NY. This website is statically generated with with Material for MkDocs and GitHub Actions. Additionally, we use Web3Forms for a simple submission to send its organizers an email.
4+
5+
## How to Contribute
6+
Pull requests are welcome! If you'd like to contribute to the website, please follow these steps:
7+
1. Clone the repository
8+
2. Create a new branch for your changes
9+
3. Make your changes
10+
4. Test your changes locally
11+
5. Push your changes to your fork
12+
6. Create a pull request
13+
14+
Your PR must be approved before merging. It will be reviewed for content, style, and adherence to the code of conduct. After merging, the GitHub Action defined in `.github/workflows/ci.yml` will publish the changes to RocPy's organization GitHub Page.

docs/contact.md

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,20 @@
11
# Contact Us
22

3-
<script>
4-
const form = document.getElementById("contactForm");
5-
const submitBtn = document.getElementById("submitBtn");
6-
const messageStatus = document.getElementById("messageStatus");
7-
8-
form.addEventListener("submit", async function (event) {
9-
event.preventDefault();
10-
11-
// Clear old messages & set button state
12-
messageStatus.style.display = "none";
13-
messageStatus.classList.remove("success", "error");
14-
messageStatus.textContent = "";
15-
submitBtn.disabled = true;
16-
submitBtn.innerText = "Sending...";
17-
18-
const formData = new FormData(form);
19-
20-
try {
21-
const response = await fetch("https://api.web3forms.com/submit", {
22-
method: "POST",
23-
body: formData,
24-
});
25-
const json = await response.json();
26-
27-
if (json.success) {
28-
// Show success block
29-
messageStatus.textContent = "✓ Message sent successfully!";
30-
messageStatus.classList.add("success");
31-
messageStatus.style.display = "block";
32-
33-
// Optionally reset the form
34-
form.reset();
35-
} else {
36-
// Show error block
37-
messageStatus.textContent =
38-
"✗ An error occurred: " + (json.message || "Please try again later.");
39-
messageStatus.classList.add("error");
40-
messageStatus.style.display = "block";
41-
}
42-
} catch (error) {
43-
// Network or unexpected error
44-
messageStatus.textContent = "✗ Could not send message. " + error.message;
45-
messageStatus.classList.add("error");
46-
messageStatus.style.display = "block";
47-
} finally {
48-
submitBtn.disabled = false;
49-
submitBtn.innerText = "Send Message";
50-
}
51-
});
52-
</script>
53-
543
<form
554
action="https://api.web3forms.com/submit"
565
method="POST"
576
class="contact-form"
587
id="contactForm"
598
>
609
<!-- 1) Your Access Key from Web3Forms -->
61-
<input type="hidden" name="access_key" value="9c04327a-dea1-4938-8b84-37de91941a7b" />
10+
<!-- <input type="hidden" name="access_key" value="9c04327a-dea1-4938-8b84-37de91941a7b" /> -->
6211
6312
<!-- Uncomment below to test emails without sending them -->
6413
<!-- <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY_HERE"> -->
14+
<input type="hidden" name="access_key" value="473220fe-064b-4ae1-a212-7a8458491ea5">
6515

6616
<!-- 2) Optional honeypot field for spam control -->
67-
<input type="hidden" name="honeypot" value="" />
17+
<input type="checkbox" name="botcheck" class="hidden" style="display: none;">
6818

6919
<!-- Optional: But Recommended: To Prevent SPAM Submission. Make sure its hidden by default -->
7020
<input type="checkbox" name="botcheck" id="" style="display: none;">
@@ -73,7 +23,7 @@
7323
<!-- <input type="hidden" name="redirect" value="https://example.com/thank-you" /> -->
7424

7525
<!-- 4) Form "from" name -->
76-
<input type="hidden" name="RocPy Contact Noticfication" value="Mission Control">
26+
<input type="hidden" name="from_name" value="RocPy Contact Notification">
7727

7828
<div class="input-group">
7929
<label for="name">Name</label>
@@ -124,3 +74,55 @@
12474

12575
<!-- Hidden by default; shown on success or error -->
12676
<div id="messageStatus" class="message-status" style="display: none;"></div>
77+
78+
79+
<script>
80+
const form = document.getElementById("contactForm");
81+
const submitBtn = document.getElementById("submitBtn");
82+
const messageStatus = document.getElementById("messageStatus");
83+
84+
form.addEventListener("submit", async function (event) {
85+
event.preventDefault();
86+
87+
// Clear old messages & set button state
88+
messageStatus.style.display = "none";
89+
messageStatus.classList.remove("success", "error");
90+
messageStatus.textContent = "";
91+
submitBtn.disabled = true;
92+
submitBtn.innerText = "Sending...";
93+
94+
const formData = new FormData(form);
95+
96+
try {
97+
const response = await fetch("https://api.web3forms.com/submit", {
98+
method: "POST",
99+
body: formData,
100+
});
101+
const json = await response.json();
102+
103+
if (json.success) {
104+
// Show success block
105+
messageStatus.textContent = "✓ Message sent successfully!";
106+
messageStatus.classList.add("success");
107+
messageStatus.style.display = "block";
108+
109+
// Optionally reset the form
110+
form.reset();
111+
} else {
112+
// Show error block
113+
messageStatus.textContent =
114+
"✗ An error occurred: " + (json.message || "Please try again later.");
115+
messageStatus.classList.add("error");
116+
messageStatus.style.display = "block";
117+
}
118+
} catch (error) {
119+
// Network or unexpected error
120+
messageStatus.textContent = "✗ Could not send message. " + error.message;
121+
messageStatus.classList.add("error");
122+
messageStatus.style.display = "block";
123+
} finally {
124+
submitBtn.disabled = false;
125+
submitBtn.innerText = "Send Message";
126+
}
127+
});
128+
</script>

0 commit comments

Comments
 (0)