I have written following code to find out palindrome number/string.
<!doctype html>
<html>
<head>
<script>
function Palindrom() {
var rev="";
var str= document.getElementById("name1").value;
for ( var i=str.lenght; i>=0; i--)
{
var rev=rev + str.charAt(i);
}
if (str == rev)
{
alert ("Enter value is palindrome");
}
else
{alert ("Value is not palindrome");}
}
</script>
</head>
<body>
Enter String:<input type="text" name="Name" id="name1">
<button type="button" onclick="Palindrom();"> Check it</button>
</body>
</html>
However, it is giving the o/p of else statement even i am entering palindrome string in the box.. I don;t think there is something wrong. please correct the code and explain what was wrong. Thank you, sameer