-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpalindrome.html
43 lines (38 loc) · 1.01 KB
/
palindrome.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Palindrome</title>
<script type="text/javascript">
function isPalindrome()
{
var str = document.getElementById("str").value;
document.getElementById("answer").innerHTML = "";
var len = str.length;
for(i=0; i<len;i++)
{
if(str[i]!=str[len-i-1])
{
break;
}
}
if(i==len)
{
document.getElementById("answer").innerHTML +="<h1 style='color:green'>Palindrome !!!</h1>";
}
else
{
document.getElementById("answer").innerHTML +="<h1 style='color:red'>Not a Palindrome !!!</h1>";
}
}
</script>
</head>
<body>
<div class="input-group">
<span class="input-group-addon"></span>
<input type="text" class="form-control" id="str" placeholder="Enter the string">
<button onclick="isPalindrome()">Check</button>
<p id="answer"></p>
</div>
</body>
</html>