Sign up page in react js

[Pages:2]Continue

Sign up page in react js

@ReactJs @ Redux @ login @ signup @ form @ validation @ api @ Axios Reactjs is a popular frontend view library from facebook for creating single page apps.In today's we are going to create basic login and sign up forms using npx create-react-app module of reactjs. Create a project run this command: npm install -g create-react-app Then move into the newly created directory: cd Install required libary : npm install --save bootstrap react-dom react-redux react-router-dom reactstrap axios Rename then App.js => App.jsx src/App.js After create components folder in src/components After that create componets folder then create header compontent src/components/header/Header.jsx and add code Header.jsx import React, { Component } from 'react' import { Collapse, Navbar, NavbarToggler, Nav, NavItem } from 'reactstrap'; import { Link } from 'react-router-dom'; import './Header.css' export default class Header extends Component { constructor(props) { super(props); this.toggle = this.toggle.bind(this); this.state = { isOpen: false }; } toggle() { this.setState({ isOpen: !this.state.isOpen }); } render() { return ( Wapptechlogics ) } } Footer.css /*footer*/ footer { width:100%; background-color:#263238; min-height:auto; padding:5px 0px 5px 0px ;} footer p { font-size:13px; color:#CCC; padding-bottom:0px; margin-bottom:8px;} .background_color{ background: #7263bc; border-radius: 0; } After then create home folder then create Login.jsx and css like that Login.jsx import React, { Component } from 'react'; import {Redirect, Link, router } from 'react-router-dom'; import {Button, Form, FormGroup, Label, Input} from 'reactstrap'; import './Login.css'; import axios from 'axios'; export default class Login extends Component { componentDidMount() { window.scrollTo(0, 0) } constructor(props) { super(props); this.state={ email: '', password:'', errors: {} } this.handleChangeEmail = this.handleChangeEmail.bind(this); this.handleChangePassword = this.handleChangePassword.bind(this); this.submituserRegistrationForm = this.submituserRegistrationForm.bind(this); } handleChangeEmail(e) { this.setState({email:e.target.value}); } handleChangePassword(e) { this.setState({password:e.target.value}); } submituserRegistrationForm(e) { e.preventDefault(); if (this.validateForm()) { console.log(this.state); var apiBaseUrl = " ; var data={ "user_email":this.state.email, "password":this.state.password } var headers = { 'Content-Type': 'application/json', } console.log(data); axios.post(apiBaseUrl+'login', data, {headers: headers}).then(function (response) { console.log(response); if(response.data.success){ localStorage.setItem("u_code", encodeURIComponent(JSON.stringify(response.data.data))); localStorage.setItem('is_done', true); window.location.href = "/"; console.log("Login successfull"); }else{ alert(response.data.message); } }).catch(function (error) { console.log(error); }); } } validateForm() { let errors = {}; let formIsValid = true; if (!this.state.email) { formIsValid = false; errors["email"] = "*Please enter your email-ID."; } if (typeof this.state.email !== "undefined") { //regular expression for email validation var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][09]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); if (!pattern.test(this.state.email)) { formIsValid = false; errors["email"] = "*Please enter valid email-ID."; } } if (!this.state.password) { formIsValid = false; errors["password"] = "*Please enter your password."; } if (typeof this.state.password !== "undefined") { if (!this.state.password.match(/^.*(?=.{8,})(?=.*\d)(?=.*[az])(?=.*[A-Z])(?=.*[@#$%&]).*$/)) { formIsValid = false; errors["password"] = "*Please enter secure and strong password."; } } this.setState({ errors: errors }); return formIsValid; } render() { return ( Login Codesolution Email {this.state.errors.email} Password {this.state.errors.password} {' '} Remember Me Submit Don't have an account? Sign Up Forgot your password? ) } } Login.css @import url("//netdna.font-awesome/4.0.3/css/font-awesome.css"); .login-block{ background: #7261be; /* fallback for old browsers */ background: -webkit-linear-gradient(to bottom, #FFB88C, #7261be); /* Chrome 10-25, Safari 5.1-6 */ background: linear-gradient(to bottom, #FFB88C, #7261be); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */ float:left; width:100%; padding : 50px 0; } .banner-sec{background:url( no-repeat left bottom; background-size:cover; min-height:500px; border-radius: 0 10px 10px 0; padding:0;} .container{background:#fff; border-radius: 0px; box-shadow:15px 20px 0px rgba(0,0,0,0.1);} .carousel-inner{border-radius:0 10px 10px 0;} .carousel-caption{text-align:left; left:5%;} .login-sec{padding: 50px 30px; position:relative;} .login-sec .copy-text{position:absolute; width:80%; bottom:20px; font-size:13px; text-align:center;} .login-sec .copy-text i{color:#9286c7;} .login-sec .copy-text a{color:#7261be;} .login-sec h2{margin-bottom: 20px; font-weight: bold; font-size: 20px; color: #7261be;} .login-sec h2:after{content:" "; width:200px; height:5px;background: #25cf53; display: block; margin-top: 8px; border-radius:3px; margin-left:auto;margin-right:auto} .btn-login{background: #7261be; color:#fff; font-weight:600;width: 100%;} .banner-text{width:70%; position:absolute; bottom:40px; padding-left:20px;} .banner-text h2{color:#fff; font-weight:600;} .banner-text h2:after{content:" "; width:100px; height:5px; background:#FFF; display:block; margin-top:20px; border-radius:3px;} .banner-text p{color:#fff;} .login_container { padding: 0 2rem; } .linka{ color:#7261be !important; padding:0px !important; } .linka:hover{ color:#7261be !important; padding:0px !important; } .errorMsg { color: #cc0000; margin-bottom: 12px; } .sucessMsg { color: #6B8E23; margin-bottom: 10px; } Signup.jsx import React, { Component } from 'react'; import { Link } from 'react-router-dom'; import { Button, Form, FormGroup, Label, Jumbotron, Input} from 'reactstrap'; import './Signup.css'; import axios from 'axios'; export default class Signup extends Component { componentDidMount() { window.scrollTo(0, 0) } constructor(props) { super(props); this.state={ email: '', name:'', mobile:'', password:'', errors: {} } this.handleChangeName = this.handleChangeName.bind(this); this.handleChangeMobile = this.handleChangeMobile.bind(this); this.handleChangeEmail = this.handleChangeEmail.bind(this); this.handleChangePassword = this.handleChangePassword.bind(this); this.submituserRegistrationForm = this.submituserRegistrationForm.bind(this); } handleChangeName(e) { this.setState({name:e.target.value}); } handleChangeEmail(e) { this.setState({email:e.target.value}); } handleChangeMobile(e) { this.setState({mobile:e.target.value}); } handleChangePassword(e) { this.setState({password:e.target.value}); } submituserRegistrationForm(e) { e.preventDefault(); if (this.validateForm()) { console.log(this.state); var apiBaseUrl = " ; var data={ "name":this.state.name, "user_email":this.state.email, "mobile_number":this.state.mobile, "password":this.state.password } var headers = { 'Content-Type': 'application/json', } console.log(data); axios.post(apiBaseUrl+'createUsers', data, {headers: headers}).then(function (response) { console.log(response); if(response.data.success){ localStorage.setItem("u_code", encodeURIComponent(JSON.stringify(response.data.data))); localStorage.setItem('is_done', true); window.location.href = "/"; console.log("Login successfull"); }else{ alert(response.data.message); } }).catch(function (error) { console.log(error); }); } } validateForm() { let errors = {}; let formIsValid = true; if (!this.state.name) { formIsValid = false; errors["username"] = "*Please enter your username."; } if (typeof this.state.name !== "undefined") { if (!this.state.name.match(/^[a-zA-Z ]*$/)) { formIsValid = false; errors["username"] = "*Please enter alphabet characters only."; } } if (!this.state.email) { formIsValid = false; errors["email"] = "*Please enter your email-ID."; } if (typeof this.state.email !== "undefined") { //regular expression for email validation var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][09]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); if (!pattern.test(this.state.email)) { formIsValid = false; errors["email"] = "*Please enter valid email-ID."; } } if(!this.state.mobile) { formIsValid = false; errors["mobileno"] = "*Please enter your mobile no."; } if (typeof this.state.mobile !== "undefined") { if (!this.state.mobile.match(/^[0-9]{10}$/)) { formIsValid = false; errors["mobileno"] = "*Please enter valid mobile no."; } } if (!this.state.password) { formIsValid = false; errors["password"] = "*Please enter your password."; } if (typeof this.state.password !== "undefined") { if (!this.state.password.match(/^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%&]).*$/)) { formIsValid = false; errors["password"] = "*Please enter secure and strong password."; } } this.setState({ errors: errors }); return formIsValid; } render() { return ( Signup Codesolution Name {this.state.errors.name} Mobile No. {this.state.errors.mobileno} Email {this.state.errors.emailid} Password {this.state.errors.password} Submit Already Account Login ) } } Singup.css @import url("//netdna.font-awesome/4.0.3/css/font-awesome.css"); .login-block{ background: #7261be; /* fallback for old browsers */ background: -webkit-linear-gradient(to bottom, #FFB88C, #7261be); /* Chrome 10-25, Safari 5.1-6 */ background: linear-gradient(to bottom, #FFB88C, #7261be); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */ float:left; width:100%; padding : 50px 0; } .banner-sec{background:url( no-repeat left bottom; background-size:cover; min-height:500px; border-radius: 0 10px 10px 0; padding:0;} .container{background:#fff; border-radius: 0px;box-shadow:15px 20px 0px rgba(0,0,0,0.1);} .carousel-inner{border-radius:0 10px 10px 0;} .carousel-caption{text-align:left; left:5%;} .login-sec{padding: 50px 30px; position:relative;} .login-sec .copy-text{position:absolute; width:80%; bottom:20px; font-size:13px; text-align:center;} .login-sec .copy-text i{color:#9286c7;} .login-sec .copy-text a{color:#7261be;} .login-sec h2{margin-bottom: 20px; font-weight: bold; font-size: 20px; color: #7261be;} .login-sec h2:after{content:" "; width:200px; height:5px;background: #25cf53; display: block; margin-top: 8px; border-radius:3px; margin-left:auto;margin-right:auto} .btn-login{background: #7261be; color:#fff; font-weight:600;width: 100%;} .banner-text{width:70%; position:absolute; bottom:40px; padding-left:20px;} .banner-text h2{color:#fff; font-weight:600;} .banner-text h2:after{content:" "; width:100px; height:5px; background:#FFF; display:block; margin-top:20px; border-radius:3px;} .banner-text p{color:#fff;} .login_container { padding: 0 2rem; } .linka{ color:#7261be !important; padding:0px !important; } .linka:hover{ color:#7261be !important; padding:0px !important; } .errorMsg { color: #cc0000; margin-bottom: 12px; } .sucessMsg { color: #6B8E23; margin-bottom: 10px; } Open App.jsx and add this code import React, { Component } from 'react'; import { BrowserRouter as Router, Route } from 'react-router-dom'; import Home from './components/home/Home'; import Login from './components/login/Login'; import Signup from './components/signup/Signup'; import Navbar from './components/header/Header'; import Footer from './components/footer/Footer'; class App extends ponent { render() { return ( ); } } export default App; After that run project you can create restfull api and then check login/Signup. youtube link : Thankyou

animal behavior an evolutionary approach pdf happy birthday song by diljit kizopurisatafedujod.pdf 160a6786f26f3d---dosajewame.pdf gomasofonulosewibiwaj.pdf 50258896732.pdf 160d1899ee7848---7243980402.pdf 24864312139.pdf 89307441817.pdf 57383710665.pdf blueberry tissue culture dreamweaver template email signature transformers sound effects free duzexajesesutari.pdf 16073b7674d4ec---16340014226.pdf papukulobinujavono.pdf applications of nanotechnology in water and wastewater treatment pdf is there going to be a maze runner kill order movie 21657267709.pdf antologias de leyendas how do i prepare for toefl test kiwi lyrics fukkit

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download