What is Event Handling in React? Complete Beginner's Guide (2026)

Image
  What is Event Handling in React? Event Handling in React is the process of responding to user actions by executing JavaScript functions. Whenever a user interacts with a React application—such as clicking a button, typing in a text box, submitting a form, or moving the mouse—React detects that action and calls a function to perform the required task. Whenever a user clicks a button, types in an input box, submits a form, moves the mouse, or presses a keyboard key, React detects that action and executes a function. This process is called Event Handling. For example, when a user clicks a Login button, React can validate the entered username and password. When a user types in a search box, React can display matching search results immediately. Without event handling, these interactions would not be possible, and the application would remain static. Basic Syntax of Event Handling function App() {     function showMessage() {     alert("Welcome to React!"); ...

how to create contact form HTML and CSS



Creating Sample Contact Us Form Using HTML


         Contact us form

contact us form

PROGRAM :CODE

Contact Us  form


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
 
  <link href="https://maxcdn.bootstrapcdn.com
/font-awesome/4.7.0/css/font-awesome.min.css"
rel="stylesheet" integrity="sha384-
wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+
QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
crossorigin="anonymous">
  <link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/
animate.css/3.5.2/animate.css" />
  </<link rel="stylesheet" href="style.css">
<style >
*{
  box-sizing: border-box;
}

body{
 
  color:#485e74;
  line-height:1.6;
  font-family: 'Segoe UI', Tahoma,
Geneva, Verdana, sans-serif;
  padding:1em;
}

.container{
  max-width:1170px;
  margin-left:auto;
  margin-right:auto;
  padding:1em;
}

ul{
  list-style: none;
  padding:0;
}

.brand{
  text-align: center;
}

.brand span{
  color:#fff;
}

.wrapper{
  box-shadow: 0 0 20px 0 rgba(72,94,116,0.7);
}

.wrapper > *{
  padding: 1em;
}

.company-info{
  background:#c9e6ff;
}

.company-info h3, .company-info ul{
  text-align: center;
  margin:0 0 1rem 0;
}

.contact{
  background:#f9feff;
}

/* FORM STYLES */
.contact form{
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap:20px;
}

.contact form label{
  display:block;
}

.contact form p{
  margin:0;
}

.contact form .full{
  grid-column: 1 / 3;
}

.contact form button, .contact form input,
.contact form textarea{
  width:100%;
  padding:1em;
  border:1px solid #c9e6ff;
}

.contact form button{
  background:#c9e6ff;
  border:0;
  text-transform: uppercase;
}

.contact form button:hover,.contact
form button:focus{
  background:#92bde7;
  color:#fff;
  outline:0;
  transition: background-color 2s ease-out;
}

.alert{
  text-align: center;
  padding:10px;
  background:#79c879;
  color:#fff;
  margin-bottom:10px;
  display:none;
}

/* LARGE SCREENS */
@media(min-width:700px){
  .wrapper{
    display: grid;
    grid-template-columns: 1fr 2fr;
  }

  .wrapper > *{
    padding:2em;
  }
h{
color: pink;
}
  .company-info h3, .company-info ul, .brand{
    text-align: left;
  }
}
</style >
</head>
<body>
  <div class="container">
      <div class="wrapper">
      <div class="company-info">
        <h3>Macrame Art  Website</h3>
        <ul>
    <li><i class="fa fa-phone"></i>  
type the nunber</li>
      <li><i class="fa fa-envelope"></i>
type the user email for example;<br>
"createthewebsiteinhtmlcssjsbtinlowprice@gmail.
com"<br>message-the-email& informaton<br>
      to you website.busines-than create
you website </li>
        </ul>
      </div>
      <div class="contact">
        <h3>Contact us form </h3>
        <div class="alert">Your
message has been sent</div>
        <form id="contactForm">
          <p>
            <label>Name</label>
            <input type="text" name="name"
id="name" required>
          </p>
     
          <p>
            <label>Email Address</label>
            <input type="email" name="email"
id="email" required>
          </p>
          <p>
     <label>phone Number</label>
       <input type ="phone number" name
="phone number " id ="phone number " required>
      </p>
 
        <p class="full">
            <label>feedback</label>
            <textarea name="Feedback"
rows="5" id="Feedback"></textarea>
          </p>
       
       <p class="full">
        <button type="submit">Submit</button>
          </p>
        </form>
      </div>
    </div>
  </div>

  <script src="https://www.gstatic.com/
firebasejs/4.3.0/firebase.js"></script>
  <script src="main.js"></script>
<script>
// Initialize Firebase (ADD YOUR OWN DATA)

firebase.initializeApp(config);

// Reference messages collection
var messagesRef = firebase.database()
.ref('messages');

// Listen for form submit
document.getElementById('contactForm')
.addEventListener('submit', submitForm);

// Submit form
function submitForm(e){
  e.preventDefault();

  // Get values
  var name = getInputVal('name');
  var email = getInputVal('email');
 var phone number=getlnputVal('  phone number')
   var feedback = getInputVal('feedback');

  // Save message
  saveMessage(name,  email, phone number,
feedback);

  // Show alert
  document.querySelector('.alert').
style.display = 'block';

  // Hide alert after 3 seconds
  setTimeout(function(){
    document.querySelector('.alert').
style.display = 'none';
  },3000);

  // Clear form
  document.getElementById('contactForm').reset();
}

// Function to get get form values
function getInputVal(id){
  return document.getElementById(id).value;
}

// Save message to firebase
function saveMessage(name,  email,phone number,
feedback){
  var newMessageRef = messagesRef.push();
  newMessageRef.set({
    name: name,
   email:email,
   phone number: phone number,
   feedback: feedback,
  });
}
</script >
</body>
</html>

Related post 

type of css selectors

html form tag

php while loop

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example