-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReg.js
174 lines (168 loc) · 7.17 KB
/
Reg.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import React, { Component } from 'react'
class Reg extends Component {
constructor() {
super()
this.state = {
firstname: "",
lastname: "",
age: "",
dob: "",
gender: "",
course: "",
isReactjs: false,
isReactNative: false,
isHtml: false,
isPython: false
}
this.handelChange = this.handelChange.bind(this)
}
handelChange(event) {
const { name, value, type, checked } = event.target
type === "checkbox" ?
this.setState({
[name]: checked
}) :
this.setState({
[name]: value
})
}
render() {
return (
<main>
<form>
<table>
<tr>
<td>First Name : </td>
<td>
<input
placeholder="Enter first name"
type="text"
name="firstname"
value={this.state.firstname}
onChange={this.handelChange}
/>
</td>
</tr>
<tr>
<td>Last Name : </td>
<td>
<input
placeholder="Enter last name"
type="text"
name="lastname"
value={this.state.lastname}
onChange={this.handelChange}
/>
</td>
</tr>
<tr>
<td>Age : </td>
<td>
<input
placeholder="Enter age"
type="text"
name="age"
value={this.state.age}
onChange={this.handelChange}
/>
</td>
</tr>
<tr>
<td>Date of birth : </td>
<td>
<input
name="dob"
type="date"
value={this.state.dob}
onChange={this.handelChange}
placeholder="DD/MM/YYYY"
/>
</td>
</tr>
<tr>
<td>Gender : </td>
<td>
<input
type="radio"
name="gender"
value="Male"
checked={this.state.gender === "Male"}
onChange={this.handelChange}
/> Male
<input
type="radio"
name="gender"
value="Female"
checked={this.state.gender === "Female"}
onChange={this.handelChange}
/> Female
</td>
</tr>
<tr>
<td>Select Your Course : </td>
<td>
<select
name="course"
value={this.state.course}
onChange={this.handelChange}
>
<option value=""> Select your Course </option>
<option value="B-Tech">B-TECH</option>
<option value="BCA">BCA</option>
<option value="M-Tech">M-TECH</option>
<option value="MCA">MCA</option>
</select>
</td>
</tr>
<tr>
<td>Select Your Subject : </td>
<td>
<input
name="isReactjs"
onChange={this.handelChange}
checked={this.state.isReactjs}
type="checkbox"
/>React js
<input
name="isReactNative"
onChange={this.handelChange}
checked={this.state.isReactNative}
type="checkbox"
/>React
<input
name="isHtml"
onChange={this.handelChange}
checked={this.state.isHtml}
type="checkbox"
/>HTML
<input
name="isPython"
onChange={this.handelChange}
checked={this.state.isPython}
type="checkbox"
/>Python
</td>
</tr>
<br />
<tr>
<td></td>
<td><button>Submit</button></td>
</tr>
</table>
</form>
<h1>Check Information is write or wrong</h1>
<h3>Name : {this.state.firstname} {this.state.lastname}</h3>
<h3>Age : {this.state.age}</h3>
<h3>Date of birth : {this.state.dob}</h3>
<h3>You are {this.state.gender}</h3>
<h3>Your selected course {this.state.course}</h3>
<h3>Your subjects </h3>
<p>Reactjs {this.state.isReactjs ? "Yes" : "No"}</p>
<p>React Native {this.state.isReactNative ? "Yes" : "No"}</p>
<p>Html {this.state.isHtml ? "Yes" : "No"}</p>
<p>Python {this.state.isPython ? "Yes" : "No"}</p>
</main>
)
}
}
export default Reg