-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form Validate By php.php
80 lines (71 loc) · 1.59 KB
/
Form Validate By php.php
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
<!DOCTYPE html>
<html>
<head>
<script>
function validate(){
var a= document.getElementById("fname").value;
var b=/^[A-Za-z]+$/;
if(a.match(b))
{
alert("success");
}
else{
alert("fail");
}
}
</script>
</head>
<body>
<?php
if(isset($_POST['submit'])){
if(empty($_POST['fname'])){
echo "First name is required";
}
if(empty($_POST['dept name'])){
echo "department name is required";
}
if(empty($_POST['campus'])){
echo "campus name is required";
}
}
?>
<form action="answer.php" method="post">
<table align=center>
<tr>
<td>Name</td>
</tr>
<tr>
<td><input type="text" name="fname" placeholder="first"></td>
<td><input type="text" name="lname" placeholder="last"></td>
</tr>
<tr>
<td>Department</td>
<td>Student ID</td>
</tr>
<tr>
<td><select name="dept name">
<option value="">select</option>
<option value="swe">SWE</option>
<option value="cse">CSE</option>
</select>
</td>
<td><input type="text" name="studentid" placeholder="Enter your student id"></td>
</tr>
<tr>
<td>Credit Complete</td>
<td>Campus</td>
</tr>
<tr>
<td><input type="text" name="ccomplete" placeholder="enter the total number of credit you complete"></td>
<td><input type="radio" name="campus" value="mcampus">Main Campus
<input type="radio" name="campus" value="pcampus">Permanent Campus</br>
<input type="radio" name="campus" value="mcampus">Main Campus
</td>
</tr>
<tr>
<td><input type="submit" value="submit" name="submit" onclick="validate()"></td>
</tr>
</table>
</form>
</body>
</html>