content logo

React Forms:

React Subscription Form with Showing Message

You will need a form to subscribe to the newsletters on your website. If you have created other code for your website using React, this form can be used for the subscription section. The registration button in this form is blue and by clicking on it, the phrase "Hello" will be placed next to the name written in the form.

#

Free Subscribe Form

#

Simple React Form Code

#

Javascript Subscription Form

#

Subscribe form by React JS

<!-- This script got from frontendfreecode.com -->
<nav class="navbar navbar-fixed-top" id="navBar">
     <h1 class="navbar-brand mb-0">ReactJS Form</h1>
</nav>
<div id="myApp">
</div>
<div id="userInfo">
</div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
.navbar-fixed-top {
  min-height: 80px;
  background-color: #036eb1;
  width: 100% !important;
}
.navbar > h1 {
  line-height: 80px; 
  font-size: 48px; 
  color:#f8c066;
  font-family: 'Baloo', cursive; 
}
#myApp, p {
  font-family: 'Noto Sans', sans-serif; 
}
form {
  height:200px; 
  font-size: 24pt;
  margin-top: 40px;
  text-align: center;
  color: #036eb1;
}
input[type=text] {
  color: #e4455d;
}
#myBtn {
  background-color: #036eb1;
  color: #f8c066;
  
}
#userInfo {
  text-align: center; 
  font-family: 'Noto Sans', sans-serif; 
  color: #036eb1;
}
class MyForm extends React.Component {
        constructor(props) {
    super(props);
    this.state = { value: '' };
    this.handleChange = this.handleChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  }
  handleChange(event) {
        this.setState({ value: event.target.value });
  }
  handleSubmit(event) {
        ReactDOM.render( /*#__PURE__*/React.createElement("h1", null, "Hello, ", this.state.value), document.getElementById('userInfo'));
    event.preventDefault();
  }
  render() {
    return /*#__PURE__*/(
      React.createElement("form", { onSubmit: this.handleSubmit }, /*#__PURE__*/
      React.createElement("label", null, "Name:", /*#__PURE__*/
      React.createElement("input", { type: "text", value: this.state.value, onChange: this.handleChange })), "\xA0", /*#__PURE__*/
      React.createElement("input", { type: "submit", value: "Submit", id: "myBtn", placeholder: "What's ya name?" })));
  }}
ReactDOM.render( /*#__PURE__*/React.createElement(MyForm, null), document.getElementById('myApp'));
<link href="https://fonts.googleapis.com/css?family=Baloo|Noto+Sans" rel="stylesheet">
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-with-addons.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js'></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<link href="https://fonts.googleapis.com/css?family=Baloo|Noto+Sans" rel="stylesheet">
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-with-addons.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js'></script>
<style>
.navbar-fixed-top {
  min-height: 80px;
  background-color: #036eb1;
  width: 100% !important;
}
.navbar > h1 {
  line-height: 80px; 
  font-size: 48px; 
  color:#f8c066;
  font-family: 'Baloo', cursive; 
}
#myApp, p {
  font-family: 'Noto Sans', sans-serif; 
}
form {
  height:200px; 
  font-size: 24pt;
  margin-top: 40px;
  text-align: center;
  color: #036eb1;
}
input[type=text] {
  color: #e4455d;
}
#myBtn {
  background-color: #036eb1;
  color: #f8c066;
  
}
#userInfo {
  text-align: center; 
  font-family: 'Noto Sans', sans-serif; 
  color: #036eb1;
}
</style>

</head>
<body>
<nav class="navbar navbar-fixed-top" id="navBar">
     <h1 class="navbar-brand mb-0">ReactJS Form</h1>
</nav>
<div id="myApp">
</div>
<div id="userInfo">
</div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
class MyForm extends React.Component {
        constructor(props) {
    super(props);
    this.state = { value: '' };
    this.handleChange = this.handleChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  }
  handleChange(event) {
        this.setState({ value: event.target.value });
  }
  handleSubmit(event) {
        ReactDOM.render( /*#__PURE__*/React.createElement("h1", null, "Hello, ", this.state.value), document.getElementById('userInfo'));
    event.preventDefault();
  }
  render() {
    return /*#__PURE__*/(
      React.createElement("form", { onSubmit: this.handleSubmit }, /*#__PURE__*/
      React.createElement("label", null, "Name:", /*#__PURE__*/
      React.createElement("input", { type: "text", value: this.state.value, onChange: this.handleChange })), "\xA0", /*#__PURE__*/
      React.createElement("input", { type: "submit", value: "Submit", id: "myBtn", placeholder: "What's ya name?" })));
  }}
ReactDOM.render( /*#__PURE__*/React.createElement(MyForm, null), document.getElementById('myApp'));
</script>

</body>
</html>
Preview