Jothi's PALINDROME using HTML & JAVASCRIPT

<html>
<body>
<script type="text/javascript">
  function Palindrome() {
   var revStr = "";
   var str = document.getElementById("str").value;
   var i = str.length;
   for(var j=i; j>=0; j--) {
      revStr = revStr+str.charAt(j);
   }
   if(str == revStr) {
      alert(str+" -is Palindrome");
   } else {
      alert(str+" -is not a Palindrome");
   }
}
</script>
<form >
  Enter a String/Number: <input type="text" id="str" name="string" /><br />
  <input type="submit" value="Check" onclick="Palindrome();"/>
</form>
</body>
</html>

No comments:

Post a Comment