Skip to content

Instantly share code, notes, and snippets.

Created October 22, 2011 19:50
What would you like to do?
MaximumWeightAttribute custom attribute jQuery unobtrusive client side validation implementation
<script type="text/javascript">
function (value, element, parameters) {
var carrier = $("#" + parameters["dependentproperty"]).val();
var carriervalue = parameters["dependentvalue"].toString();
var weightvalue = Number(parameters["weightvalue"]);
if (carrier == carriervalue && value > weightvalue) {
return false;
return true;
["weightvalue", "dependentproperty", "dependentvalue"],
function (options) {
options.rules["maximumweight"] = {
weightvalue: options.params["weightvalue"],
dependentproperty: options.params["dependentproperty"],
dependentvalue: options.params["dependentvalue"]
options.messages["maximumweight"] = options.message;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment