Parsing jQuery Unobtrusive Validation Parameters

Client-side parsing of unubtrusive jQuery validation parameters. Assuming we are setting up an unobtrusive validator named “validatorname” and want to pass “parameterfromserver” from the the server:

$.validator.unobtrusive.adapters.add('validatorname', ['parameterfromserver'], function(options) {
	options.rules['validatorname'] = {
		parameterfromserver: options.params['parameterfromserver']
	options.messages['validatorname'] = options.message;
$.validator.addMethod('validatorname', function(value, element, parameters) {
	var hereIsOurParameter = parameters.parameterfromserver;

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.