Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created August 3, 2014 15:07
Show Gist options
  • Save trikitrok/7f27a83bdb076c676291 to your computer and use it in GitHub Desktop.
Save trikitrok/7f27a83bdb076c676291 to your computer and use it in GitHub Desktop.
var customValidations = (function() {
function reverse(word) {
var i, reversedLetters = [];
for (i = word.length - 1; i >= 0; i--) {
reversedLetters.push(word[i]);
}
return reversedLetters.join('');
}
return {
isPalindrome: function(word) {
return reverse(word) === word;
}
}
})();
$.validator.addMethod("palindrome", function(value) {
return customValidations.isPalindrome(value);
});
$("#exampleForm").validate();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment