Javascript Palindrome Checker

Simple javascript that allows you to check whether a given word / string is a Palindrome or not. A palindrome is a word or phrase which reads the same forward or reverse direction.

Features

  • Used to reverse the string and check the given word is palindrome or not.
  • The checker returns true or false upon comparision.
  • The script considers spaces, punctuation marks, upper and lower cases.

Preview

Enter a word:
Reversed String
Is the word a palindrom?
©hscripts.com

Downloads

Javascript Code


<!-- Script by hscripts.com -->
<!-- More scripts @www.hscripts.com -->
<script type="text/javascript">
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){return (str == reverse_string(str));
}
function palindrome_check(){var str = document.getElementById('inputstr').value;
if(str!=""){document.getElementById('reversestr').value=reverse_string(str);document.getElementById('ispalin').value=palindrome(str);return true;}else alert ('Enter String');
}
</script>
<!-- Script by hscripts.com -->




HTML Code


<table align=center style='border:1px solid green;color: #3D366F;font-size:13px;' cellpadding=5 cellspacing=5>


<tr><td>Enter the word:<input type="text" id="inputstr" size="6"></td></tr>

<tr><td><input type="button" value="Reverse Word" onclick="palindrome_check();">

<input type="text" id="reversestr" size="6""></td></tr>

<tr><td>Is the word a palindrom?<input type="text" id="ispalin" size="4" value="">

</td></tr>

<tr>

<td align=center>

<a href='https://www.hscripts.com' style='text-decoration:none;font-size:10;color:green;'>&copy;hscripts.com</a>

</td>

</tr>

</table>


  • Release Date - 18-09-2009
  • Get free version without ©copyright link for just $10/-
  • For customization of this script or any script development, mail to support@hscripts.com

Usage

  • Copy and paste the javascript code into your HTML page to enable word checker.
  • Here, the function "palindrome_check()" is used to reverse and check the given string is palindrome or not.

License

Related Scripts

Free Javascript Scripts


Ask Questions

Ask Question