Guest User

Untitled

a guest
May 26th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. import React from 'react'
  2.  
  3. export default class SignUp extends React.Component {
  4. constructor(props) {
  5. super(props)
  6. this.state = {
  7. email: '',
  8. password: '',
  9. passVer: '',
  10. firstName: '',
  11. lastName: ''
  12. }
  13. this.updateEmailField = this.updateEmailField.bind(this)
  14. this.updatePassword = this.updatePassword.bind(this)
  15. this.updatePassVer = this.updatePassVer.bind(this)
  16. this.updateFN = this.updateFN.bind(this)
  17. this.updateLN = this.updateLN.bind(this)
  18. this.handleSubmit = this.handleSubmit.bind(this)
  19. }
  20.  
  21. updateEmailField(e) {
  22. this.setState({email: e.target.value})
  23. }
  24.  
  25. updatePassword(e) {
  26. this.setState({password: e.target.value})
  27. }
  28.  
  29. updatePassVer(e) {
  30. this.setState({passVer: e.target.value})
  31. }
  32.  
  33. updateFN(e) {
  34. this.setState({firstName: e.target.value})
  35. }
  36.  
  37. updateLN(e) {
  38. this.setState({lastName: e.target.value})
  39. }
  40.  
  41. handleSubmit(e) {
  42. if (this.state.password !== this.state.passVer) {
  43. alert('Passwords ain\'t the same')
  44. } else {
  45. console.log(this.state)
  46. }
  47. }
  48.  
  49. render() {
  50. return (<div>
  51. <h1>{JSON.stringify(this.state)}</h1>
  52. <form onSubmit={this.handleSubmit}>
  53. <input onChange={this.updateEmailField} placeholder='type your email here m8'/>
  54. <input type='password' onChange={this.updatePassword} placeholder='type your password'/>
  55. <input type='password' onChange={this.updatePassVer} placeholder='verify your password'/>
  56. <input type='text' onChange={this.updateFN} placeholder='Enter your first name'/>
  57. <input type='text' onChange={this.updateLN} placeholder='Enter your last name'/>
  58. <input type='submit' value='Submit'/>
  59. </form>
  60. </div>)
  61. }
  62. }
Add Comment
Please, Sign In to add comment