content logo

React Forms:

React Registration Form Code with Welcome Message

In this post, we have prepared a form that uses React. The advantage of React is the very low volume of HTML code. Using this code, you can get user profiles on your website and register them. This form has a title at the top of the form and the entire border form is blue.

#

Simple Registration Form

#

HTML React Form

#

React Signup Form Code

#

User Information Form

#

HTML Wlecome Message

<!-- This script got from frontendfreecode.com -->
<div id="app"></div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
@import url("https://fonts.googleapis.com/css?family=Archivo+Black");
html, body {
  height: 100%;
}
body {
  background: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: Helvetica Neue;
}
h1 {
  font-size: 4em;
  font-weight: bold;
  color: darkslategray;
  font-family: "Archivo Black";
}
.form {
  height: 35%;
  border: 5px solid #BED8D4;
  border-radius: 20%;
  margin-top: 1em;
  text-align: center;
  justify-content: center;
  flex-direction: column;
  background-color: #F7F9F9;
  display: flex;
  padding: 45px;
}
.inputcontainer {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
input {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 5px;
}
button {
  justify-content: center;
  align-items: center;
  margin: 2em;
}
function _defineProperty(obj, key, value) {if (key in obj) {Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });} else {obj[key] = value;}return obj;} //In the Settings for this pen, I've selected Babel for a Javascript preprocessor. 
class Application extends React.Component {
  constructor(props) {
    super(props);
    _defineProperty(this, "inputCheck",
    e => {
      let filter = e.target.getAttribute('filter');
      e.target.value = e.target.value.replace(new RegExp(filter, 'g'), '');
      this.setState({ [e.target.name]: e.target.value });
    });_defineProperty(this, "submitCheck",
    () => {
      if (!this.state.firstName || !this.state.lastName) {
        alert("A name field is empty.");
      } else if (this.state.phone.length < 10 || !this.state.phone) {
        alert("Phone number is not long enough.");
      } else if (!this.state.email.match(/@./g)) {
        alert("Email is in the wrong format.");
      } else {
        this.setState({ display: true });
      }
    });_defineProperty(this, "resetForm",
    () => {
      this.setState({
        display: !this.state.display,
        firstName: '',
        lastName: '',
        phone: 0,
        email: '' });
    });this.state = { 
      display: false, firstName: "", lastName: "", phone: 0, email: "" };}
  displayForm() {
    return /*#__PURE__*/(
      React.createElement("div", { className: "form" }, /*#__PURE__*/
      React.createElement("div", { className: "header" }, /*#__PURE__*/
      React.createElement("h1", null, "Welcome!"), /*#__PURE__*/
      React.createElement("p", null, "Please provide your information below.")), /*#__PURE__*/
      React.createElement("div", { className: "inputcontainer" }, /*#__PURE__*/
      React.createElement("input", { filter: "[^a-zA-Z ]", name: "firstName", placeholder: "First Name", onChange: this.inputCheck }), /*#__PURE__*/
      React.createElement("input", { filter: "[^a-zA-Z ]", name: "lastName", placeholder: "Last Name", onChange: this.inputCheck }), /*#__PURE__*/
      React.createElement("input", { filter: "[^0-9]", maxLength: "10", name: "phone", placeholder: "Phone Number", onChange: this.inputCheck }), /*#__PURE__*/
      React.createElement("input", { placeholder: "Email Address", onChange: e => {this.setState({ email: e.target.value });} }), /*#__PURE__*/
      React.createElement("button", { onClick: this.submitCheck }, "Submit"))));
  }
   displayData() {
    return /*#__PURE__*/(
      React.createElement("div", { className: "form" }, /*#__PURE__*/
      React.createElement("p", null, this.state.lastName, ", ", this.state.firstName), /*#__PURE__*/
      React.createElement("p", null, this.state.phone, " | ", this.state.email), /*#__PURE__*/
      React.createElement("button", { onClick: this.resetForm }, "Reset")));
  }
  render() {
    {}
    return this.state.display ? this.displayData() : this.displayForm();
  }}
{}
ReactDOM.render( /*#__PURE__*/React.createElement(Application, null), document.getElementById('app'));
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-dom.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react-redux/5.0.6/react-redux.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/redux/4.0.0-beta.1/redux.js'></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-dom.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react-redux/5.0.6/react-redux.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/redux/4.0.0-beta.1/redux.js'></script>
<style>
@import url("https://fonts.googleapis.com/css?family=Archivo+Black");
html, body {
  height: 100%;
}
body {
  background: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: Helvetica Neue;
}
h1 {
  font-size: 4em;
  font-weight: bold;
  color: darkslategray;
  font-family: "Archivo Black";
}
.form {
  height: 35%;
  border: 5px solid #BED8D4;
  border-radius: 20%;
  margin-top: 1em;
  text-align: center;
  justify-content: center;
  flex-direction: column;
  background-color: #F7F9F9;
  display: flex;
  padding: 45px;
}
.inputcontainer {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
input {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 5px;
}
button {
  justify-content: center;
  align-items: center;
  margin: 2em;
}
</style>

</head>
<body>
<div id="app"></div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
function _defineProperty(obj, key, value) {if (key in obj) {Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });} else {obj[key] = value;}return obj;} //In the Settings for this pen, I've selected Babel for a Javascript preprocessor. 
class Application extends React.Component {
  constructor(props) {
    super(props);
    _defineProperty(this, "inputCheck",
    e => {
      let filter = e.target.getAttribute('filter');
      e.target.value = e.target.value.replace(new RegExp(filter, 'g'), '');
      this.setState({ [e.target.name]: e.target.value });
    });_defineProperty(this, "submitCheck",
    () => {
      if (!this.state.firstName || !this.state.lastName) {
        alert("A name field is empty.");
      } else if (this.state.phone.length < 10 || !this.state.phone) {
        alert("Phone number is not long enough.");
      } else if (!this.state.email.match(/@./g)) {
        alert("Email is in the wrong format.");
      } else {
        this.setState({ display: true });
      }
    });_defineProperty(this, "resetForm",
    () => {
      this.setState({
        display: !this.state.display,
        firstName: '',
        lastName: '',
        phone: 0,
        email: '' });
    });this.state = { 
      display: false, firstName: "", lastName: "", phone: 0, email: "" };}
  displayForm() {
    return /*#__PURE__*/(
      React.createElement("div", { className: "form" }, /*#__PURE__*/
      React.createElement("div", { className: "header" }, /*#__PURE__*/
      React.createElement("h1", null, "Welcome!"), /*#__PURE__*/
      React.createElement("p", null, "Please provide your information below.")), /*#__PURE__*/
      React.createElement("div", { className: "inputcontainer" }, /*#__PURE__*/
      React.createElement("input", { filter: "[^a-zA-Z ]", name: "firstName", placeholder: "First Name", onChange: this.inputCheck }), /*#__PURE__*/
      React.createElement("input", { filter: "[^a-zA-Z ]", name: "lastName", placeholder: "Last Name", onChange: this.inputCheck }), /*#__PURE__*/
      React.createElement("input", { filter: "[^0-9]", maxLength: "10", name: "phone", placeholder: "Phone Number", onChange: this.inputCheck }), /*#__PURE__*/
      React.createElement("input", { placeholder: "Email Address", onChange: e => {this.setState({ email: e.target.value });} }), /*#__PURE__*/
      React.createElement("button", { onClick: this.submitCheck }, "Submit"))));
  }
   displayData() {
    return /*#__PURE__*/(
      React.createElement("div", { className: "form" }, /*#__PURE__*/
      React.createElement("p", null, this.state.lastName, ", ", this.state.firstName), /*#__PURE__*/
      React.createElement("p", null, this.state.phone, " | ", this.state.email), /*#__PURE__*/
      React.createElement("button", { onClick: this.resetForm }, "Reset")));
  }
  render() {
    {}
    return this.state.display ? this.displayData() : this.displayForm();
  }}
{}
ReactDOM.render( /*#__PURE__*/React.createElement(Application, null), document.getElementById('app'));
</script>

</body>
</html>
Preview