-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmobval.php
More file actions
36 lines (32 loc) · 933 Bytes
/
Copy pathmobval.php
File metadata and controls
36 lines (32 loc) · 933 Bytes
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
<!DOCTYPE html>
<html>
<head>
<title>Form Validation</title>
</head>
<body>
<!-- PHP Code -->
<?php
if(isset($_POST['register'])){
$mobile=$_POST['mobile'];
if(empty($mobile)){
echo '<script>alert("Mobile Number field Empty...!!!!!!");</script>';
}elseif(!preg_match("/^\d{10}+$/", $mobile)){
echo '<script>alert("Only Numbers with 10 Digits required");</script>';
}else{
echo "<center><h2>Mobile Number:-$mobile</h2></center>";
}
}
?>
<!-- PHP Code -->
<center><h1>Mobile Number Validation in PHP</h1></center>
<form action="" method="POST">
<table align="center" style="margin-top: 200px;border: solid #ffaaff 2px;">
<tr>
<td>Mobile No</td>
<td><input type="text" name="mobile"></td>
</tr>
<tr><td></td><td align="center"><input type="submit" name="register" value="Register"></td></tr>
</table>
</form>
</body>
</html>