Guest User

Untitled

a guest
Sep 18th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. // Component state:
  2.  
  3. this.state = {
  4. name: '',
  5. username: '',
  6. password: '',
  7. passwordConf: '',
  8. email: '',
  9. mobile: '',
  10. emailInvalid: false
  11. };
  12.  
  13.  
  14.  
  15. // Example of an input:
  16.  
  17. <input id="name"
  18. value={name}
  19. placeholder={content.page.Signup.name}
  20. onChange={this.onChange}/>
  21.  
  22.  
  23.  
  24. // this.onChange Method
  25.  
  26. onChange(event) {
  27. const {
  28. id,
  29. value
  30. } = event.target;
  31.  
  32. console.log(validate({ [id]: value }));
  33.  
  34. if (validate({ [id]: value }).hasValidationErrors) { console.log('! ERROR !'); }
  35.  
  36. this.setState({ [id]: value });
  37. }
Add Comment
Please, Sign In to add comment