-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.js
53 lines (43 loc) · 1.52 KB
/
Form1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React,{Component} from "react";
class Form1 extends Component{
state={
Name:'',
Contact: '',
Message:'',
};
handleChange=(event)=>{
this.setState({Name:event.target.value});
};
handleChange1=(event)=>{
this.setState({Contact:event.target.value});
};
handleChange2=(event)=>{
this.setState({Message:event.target.value});
};
handleSubmit=(event)=>{
alert('Name: '+ this.state.Name+'\n' +'Contact: '+ this.state.Contact+'\n' + 'Message:'+this.state.Message);
event.preventDefault();
};
render()
{
return(
<form onSubmit={this.handleSubmit}>
<label>
Name:
<input type="text" value={this.state.Name} onChange={this.handleChange}/>
</label><br></br>
<label>
Contact:
<input type="number" value={this.state.Contact} onChange={this.handleChange1}/>
</label><br></br>
<label>
Message:
<input type="text" value={this.state.Message} onChange={this.handleChange2}/>
</label><br></br>
<input type="Reset" value="Reset"></input>
<input type="submit" value="submit"></input>
</form>
);
}
}
export default Form1;