-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegEx_ex.html
50 lines (48 loc) · 1.18 KB
/
RegEx_ex.html
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
<html>
<head>
<script language="javascript">
function checkNumeric()
{
//alert("this is it");
var inString=document.getElementById("num").value;
//document.write(inString);
//regular expression for numeric value
var nReg=/\b(\d)+\b/;
if(nReg.test(inString))
{
document.getElementById("res").value="true";
document.getElementById("form1").submit();
}
else
{
document.getElementById("res").value="false";
}
}
function checkDomain()
{
alert("this is in check domain");
var domString=document.getElementById("domain").value;
var finString1=domString.replace(/^w{3}\.|http[s]?:\/\//,"");
var finString=finString1.replace(/(.\w*.\w*)?$/,"");
document.write
document.write(finString);
}
</script>
</head>
<body>
<b>Numeric regualar expression check</b>
<br />
<form id="form1" action="http://www.google.com/">
enter no<input type="textbox" id="num">
<input type="button" value="submit" onclick="checkNumeric()">
result<input type="textbox" id="res">
<br />
</form>
<form>
<b>domain/subdomain check</b>
enter no<input type="textbox" id="domain">
<input type="button" value="submit" onclick="checkDomain()">
<br />
</form>
</body>
</html>