Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. render: function() {
  2.  
  3. <div>
  4. <label for="username">User:</label>
  5. <input type="text" ref='username' id='username' type='text'/>
  6.  
  7. <label for="password">Password:</label>
  8. <input ref='password' id='password' type='password' errorMessage="Password is required"/>
  9.  
  10. <a onClick={this.submit} className="btn btn-primary">Login</a>
  11.  
  12. </div>
  13. }
  14.  
  15.  
  16. submit: function() {
  17.  
  18. var username = ReactDOM.findDOMNode(this.refs.username).value;
  19. var password = ReactDOM.findDOMNode(this.refs.password).value;
  20.  
  21. this.serverRequest = $jQuery.post(url, { username: username, password: password }, function (data,success,type) {
  22.  
  23. if(type.status == 200){
  24. console.log('Good');
  25.  
  26. this.props.func(); //this is from parent which changes state of login to true
  27. }
  28. else{
  29. console.log('Wrong password/username');
  30.  
  31. //Show error next/under an input
  32. }
  33.  
  34. }.bind(this));
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement