Form Submission

Developed with
QA

Contents

keyboard_tab
ReactJS
1
React Event Forms
PREVIEW1m 17s

The course is part of this learning path

ReactJS: Zero to Hero
course-steps
14
certification
7
lab-steps
3
description
1
play-arrow
Start course
Overview
DifficultyBeginner
Duration7m
Students89

Description

This module looks at React Event Forms.  

Learning Objectives 

The objectives of this module are to provide you with an understanding of: 

  • React event forms  
  • React form components  
  • Form Submission 

Intended Audience  

This learning path is aimed at all who wish to learn how to use the ReactJS framework.  

Prerequisites

It is essential you understand the face of contemporary web development to attend this course. We insist upon JavaScript experience, along with good HTML and CSS skills. 

Feedback 

We welcome all feedback and suggestions - please contact us at qa.elearningadmin@qa.com to let us know what you think. 

Transcript

Clicking the submit button on a form raises a onsubmit event. By default, this will make a HTTP GET request, appending the form data to the URL and sending it back to the server. Obviously, this isn't a desired behavior for our React application, as it will refresh the HTML page, rebuild the DOM, and wipe out any JavaScript data we were storing. So how do we get around that? How about we intercept the onsubmit event, and have our own submit handler. We give the form an onsubmit event handler and pass the event to a function called handleSubmit. Then, we can define the handleSubmit function. The handleSubmit function takes the event and calls preventDefault to stop the HTTP request from being made. Then it takes the username state, converts it to JSON and logs it out to the Console. Clicking on the submit button in the browser demonstrates this behavior. Of course, we've shown a simple handler function to show you the mechanism. In reality, this will probably do something like validating the form data, and then sending it off in a HTTP request. We'll cover how to do that in working with external data.

Lectures

About the Author
Students2857
Labs8
Courses29
Learning paths6

An outstanding trainer in software development with more than 15 years experience as a Corporate and Apprentice Trainer, ICT Teacher and Head of Department, with a passion for technology and its uses. Continuing to develop existing and new skills and courses, primarily in web design using PHP, JavaScript, HTML, CSS and SQL but also OOP (Java), programming foundations (Using Python), DevOps (Git, CI/CD, etc) and Agile/Scrum. Practically minded, a quick learner and a problem solver with an attention to detail to ensure high quality outcomes.

Covered Topics