Why do I get the following error when doing the following inside the jQuery validation plugin by bassistance? IMO this should have worked, but I get this:
SyntaxError: missing : after property id
var type = $(this).type; //This is a hidden field in the form
$("#myForm").validate({
var type = $(this).type;
rules: {
name: {
required: true,
minlength: 3,
maxlength: 51
},
},
Why do I get the following error when doing the following inside the jQuery validation plugin by bassistance? IMO this should have worked, but I get this:
SyntaxError: missing : after property id
var type = $(this).type; //This is a hidden field in the form
$("#myForm").validate({
var type = $(this).type;
rules: {
name: {
required: true,
minlength: 3,
maxlength: 51
},
},
Share
Improve this question
edited Dec 24, 2013 at 4:52
Vishal Suthar
17.2k3 gold badges62 silver badges108 bronze badges
asked Dec 24, 2013 at 4:40
NormanNorman
6,36525 gold badges91 silver badges148 bronze badges
1
-
Like any other jQuery plugin method, you can only pass
key:value
pairs separated by mas inside of the.validate()
method. The allowedkey
s and their acceptablevalue
s are pre-defined by the plugin developer. I guess you skipped the docs. jqueryvalidation/validate – Sparky Commented Dec 25, 2013 at 16:06
1 Answer
Reset to default 4It's because the validate
method accepts object, yet you did not pass an object, try
$("#myForm").validate({
type : $(this).type,
rules: {
name: {
required: true,
minlength: 3,
maxlength: 51
},