Hi Koushik,
Check this below code for palindrome
<html><center>
<head>
<title>Palindrome Checker</title>
<script type="text/javascript" language="JavaScript">
<!--
function reverseString(the_word){
// reverseString takes a string and returns the reverse string
var rString = "";
var alen = the_word.length;
for (var i = alen ; i > 0 ; i--){
rString += the_word.charAt(i-1)
};
return rString ;
}
function palindrome(the_word){
// palindrome takes a string and returns true if and only if the string
// is a palindrome
return (the_word == reverseString(the_word));
}
function doCodeForPalin(){
// This code is the code to be executed on clicking the ``do it'' button
var aStr = document.palinForm.inputWord.value;
document.palinForm.outputWord.value = reverseString(aStr);
document.palinForm.isPalin.value = palindrome(aStr);
return true;
}
//-->
</script>
</head>
<body bgcolor="white">
<h1>Palindrome Checker</h1>
<form name="palinForm">
<p> <strong> ENTER THE WORD TO CHECK WHETHER IT IS PALINDROME OR NOT</strong> </p>
<br/>
<p>Enter your word here: <input type="text" name="inputWord"><br>
<input type="button" name=
"doIt" value="Is it Perfect?" onclick=
"doCodeForPalin();">
<input type="text" name="isPalin" value=
""><br>
<br/>
Your Input Reversed:
<input type="text" name="outputWord"><br/>
</p>
</form>
</body></center>
</html>
Jul 17, 2012