Write a JavaScript function, to check string is palindrome or not.
<html> <head> <title> Palindrome </title> <script type="text/javascript"> function checkInput(){ var str = document.form1.palindrome.value; palindrome(str); } function reverse_string(str){ var stri = ""; var alen = str.length; for (var i = alen ; i > 0 ; i--){ stri += str.charAt(i-1) } return stri; } function palindrome(str){ if(str == reverse_string(str)) alert("palindrome"); else alert("Not Palindrome"); } </script> </head> <body> <form name="form1"> Text: <input type="text" name="palindrome" /> <br /><input type="button" value="Check" onclick = "checkInput()" /> </form> </body> </html>