-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmobile.html
More file actions
42 lines (39 loc) · 1.52 KB
/
mobile.html
File metadata and controls
42 lines (39 loc) · 1.52 KB
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
<html>
<head>
<title>Regular Expressions</title>
<script type="text/javascript">
//\d : match any digit (equal to [0-9])
//\w : match any word character(a-z, A-Z, 0-9 )
//\s : match whitespace characters (spaces and tabs)
// \t : match a tab only
function validate()
{
var text=document.getElementById("text1").value;
var regx=/^[7-9]\d{9}$/;
if(regx.test(text))
{
document.getElementById("lb1text").innerHTML="valid";
document.getElementById("lb1text").style.visibility="visible";
document.getElementById("lb1text").style.color="green";
}
else
{
document.getElementById("lb1text").innerHTML="invalid";
document.getElementById("lb1text").style.visibility="visible";
document.getElementById("lb1text").style.color="red";
}
}
</script> <!--[^abc] means that we cannot have our expression starting from abc-->
<!--^[abc] specifies the starting point of our expression-->
<!--dollar denotes end of string-->
</head>
<body>
<form>
<input id="text1" placeholder="cellphone" type="text"/>
<br>
<label id="lb1text" style="color:red ; visibility:hidden">Invalid</label>
<br>
<button onclick="validate()" type="button">Submit</button>
</form>
</body>
</html>