Created
June 17, 2012 09:22
-
-
Save rogerz/2943992 to your computer and use it in GitHub Desktop.
jquery validator example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$.validator.addMethod("list", function(value, element, param) { | |
var isValid = false; | |
var list = $.parseJSON(param); | |
$.each(list, function() { | |
if (value == this) { | |
isValid = true; | |
return false; | |
}; | |
}) | |
return isValid; | |
}); | |
$("#commentForm").validate({ | |
debug: true, | |
submitHandler: function(form) { | |
alert("submit me"); | |
} | |
}); | |
$("#list").rules("add", { | |
list: '[1, 2, 3]' | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment