1. First, we need fresh reactjs setup, and for that, we need to run below commands into out terminal, and also we should have latest node version installed on our system:
npx create-react-app my-awesome-project
cd my-awesome-project
npm start
2. Now we need to run below commands into our project terminal to get bootstrap and related modules into our reactjs application:
npm install [email protected] --save
npm start //For start project again
3. Finally for the main output, we need to add below code into our my-awesome-project/src/App.js file or if you have fresh setup then you can replace my-awesome-project/src/App.js file code with below code:
import React from 'react';
import './App.css';
import 'bootstrap/dist/css/bootstrap.min.css';
function App() {
return (
<div>
<div class="container">
<div class="col-lg-8">
<form id="your_form_id" class="form-horizontal" action="" method="POST" name="your_form_id">
<div class="form-group">
<label class="col-lg-2 control-label" for="inputEmail1">First Name</label>
<div class="col-lg-10">
<input id="first_name" class="required form-control" name="first_name" type="text" placeholder="" />
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label" for="inputEmail1">Last Name</label>
<div class="col-lg-10">
<input id="last_name" class="required form-control" name="last_name" type="text" placeholder="" />
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label" for="inputEmail1">Email Address</label>
<div class="col-lg-10">
<input id="email_address" class="required form-control" name="email_address" type="text" placeholder="" />
</div>
</div>
<button id="" class="btn btn-default" type="submit">Submit</button>
</form>
</div>
</div>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.js"></script>
</div>
);
}
export default App;
4. Now we need to add below code into our my-awesome-project/src/App.css file :
body{margin-top:20px;}
.has_error{ border: 1px solid red;}