Build an Event RSVP - Build an Event RSVP

Tell us what’s happening:

I have a problem with 16(after submission, there should be an element on the page indicating the state of the email input and dietary preferences 18)

also i want to display them in the paragraphs afterwards, any suggestions, thanksa a lot!

Your code so far

<!-- file: index.html -->
<!doctype html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Event RSVP</title>
    <link rel="stylesheet" href="styles.css" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.3.1/umd/react.development.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.3.1/umd/react-dom.development.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.26.5/babel.min.js"></script>
    <script
      data-plugins="transform-modules-umd"
      type="text/babel"
      src="index.jsx"
    ></script>
    <link rel="stylesheet" href="styles.css" />
  </head>

  <body>
    <div id="root"></div>
    <script
      data-plugins="transform-modules-umd"
      type="text/babel"
      data-presets="react"
      data-type="module"
    >
      import { EventRSVPForm } from './index.jsx';
      ReactDOM.createRoot(document.getElementById('root')).render(
        <EventRSVPForm />
      );
    </script>
  </body>
</html>
/* file: styles.css */
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center; /* Horizontal */
  align-items: center;     /* Vertical */
  background-color: #f8f9fa;
}
.form-container {
  max-width: 500px;
  margin: 2rem auto;
  padding: 1.5rem;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Labels */
label {
  display: inline-block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #212529;
}

/* Inputs, Selects, Textareas */
.form-control {
  display: block;
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #212529;
  background-color: #fff;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  box-sizing: border-box;
  transition: border-color 0.15s ease-in-out,
              box-shadow 0.15s ease-in-out;
}

.form-control:focus {
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Form Groups */
.form-group {
  margin-bottom: 1rem;
}

/* Placeholder */
.form-control::placeholder {
  color: #6c757d;
  opacity: 1;
}

/* Checkbox and Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.form-check input {
  width: 1rem;
  height: 1rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.625rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  transition: all 0.15s ease-in-out;
}

.btn-primary {
  color: #fff;
  background-color: #0d6efd;
  border-color: #0d6efd;
}

.btn-primary:hover {
  background-color: #0b5ed7;
  border-color: #0a58ca;
}

/* Secondary Button */
.btn-secondary {
  color: #fff;
  background-color: #6c757d;
  border-color: #6c757d;
}

.btn-secondary:hover {
  background-color: #5c636a;
  border-color: #565e64;
}

/* Disabled Inputs */
.form-control:disabled,
.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Validation States */
.is-valid {
  border-color: #198754;
}

.is-valid:focus {
  box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

/* file: index.jsx */
const { useState } = React;
export function EventRSVPForm() {
  const [name, setName] = useState('false');
  const [email, setEmail] = useState('');
  const [number,setNumber] = useState(1);
  const [isChecked, setIsChecked] = useState(false);
  const [result, setResult] = useState(false);
  const handleChange = (e) => {
    setIsChecked(e.target.checked);
  };
  const handleSubmit = (event) => {
    event.preventDefault();
    console.log("form submitted:", name + email + isChecked + number);
  }
 return(
  <div>
  <form className="form-control" onSubmit={handleSubmit}>
  <div className="form-group"><input type="text" required value={name}  onChange={(e) => setName(e.target.value)} placeholder="Miloslav"></input></div>
  <div className="form-group">
  <input type="text"></input>
  </div>
  <div className="form-group">
  <input type="email" required value={email} onChange={(e) => setEmail(e.target.value)} placeholder="example@example.com"></input>
  </div>
  <input type="number" min="1" required value={number} onChange={(e) => setNumber(e.target.value)}>
  </input>
  <br/>
<input type="checkbox" checked={isChecked} onChange={handleChange}></input>
<p>{isChecked ? "Attend" : "Noone will attend"}</p>
<button className="btn" onClick={() => setResult(!result)}>Submit</button>
  </form>
 { result && setName && setEmail && setNumber ? name + email + number : <p>No name</p>}
  </div>
  )
;

}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36

Challenge Information:

Build an Event RSVP - Build an Event RSVP

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-event-rsvp/67d936de7055982b02baf186.md at main · freeCodeCamp/freeCodeCamp · GitHub

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.