I'm using JQUERY validator plugin on my ASP.NET web forms with a master page. Obviously the FORM element is at master page. In one of the child form I have few divs with different input blocks. So I tried to initialise the validator like this
$('#teambasic').validate({
rules: {
teamName: {
required: true,
minlength: 3
}
}
});
$('#extradetails').validate({
rules: {
domain: {
required: true,
minlength: 3
}
}
});
Each of these divs are in different steps of the wizard and on clicking next button Im calling the valid function. But on calling the function it triggers an error
jquery.validate.min.js:4 Uncaught TypeError: Cannot read property 'element' of undefined
at HTMLDivElement.<anonymous> (jquery.validate.min.js:4)
at Function.each (jquery.min.js:2)
at w.fn.init.each (jquery.min.js:2)
at w.fn.init.valid (jquery.validate.min.js:4)
at <anonymous>:1:32
On googling I found there could be a chance of this error if the inputs are outside the form tag. But in my case its all inside the FORM tag in master page. I verified its using jquery
$('input[name=teamName]').parents('form').length
which returned 1 since it has the parent form. I am not able to figure out where the trouble is
nameattribute on control to use this plugin. Are you missing name attribute ?.valid()method? Where is the rendered HTML markup? You cannot have nestedformelements with this plugin. That is invalid HTML. You also absolutely cannot attach the.valid()method to adiv, if that's what you did, hence the error message about an element.