Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- render: function() {
- <div>
- <label for="username">User:</label>
- <input type="text" ref='username' id='username' type='text'/>
- <label for="password">Password:</label>
- <input ref='password' id='password' type='password' errorMessage="Password is required"/>
- <a onClick={this.submit} className="btn btn-primary">Login</a>
- </div>
- }
- submit: function() {
- var username = ReactDOM.findDOMNode(this.refs.username).value;
- var password = ReactDOM.findDOMNode(this.refs.password).value;
- this.serverRequest = $jQuery.post(url, { username: username, password: password }, function (data,success,type) {
- if(type.status == 200){
- console.log('Good');
- this.props.func(); //this is from parent which changes state of login to true
- }
- else{
- console.log('Wrong password/username');
- //Show error next/under an input
- }
- }.bind(this));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement