I’m making my own jQuery validation plug in. What is the best method to select the input fields with an attribute of data-validate in the plugin? for clarification the plugin can be sent $('form').validate()
it possible it may be working on more than 1 form on a given page
new problem
so Im now using
var options = $.extend(defaults, options);
return this.each(function()
{
form=this;
//lazy
$(this).submit(function()
{
var o = options;
$('['+o.attr+']', form).each(function()
{
var val=$(this).val()
alert($(this).attr('name'))
})
//if errors
//encapsulate error group
//add to html with .after()
return false;
//no errors send
})
});
whats happening is that for some reason the plugin is only getting the last form. note I only have the main function of the plugin o.attr value is data-validate which works.
here is a link to the page im making it on http://yamikowebs.com/_test/project/
Usage:
Further reading: jQuery Plugin Authoring.
Edit
Bonus: Working Fiddle to illustrate it all
Edit 2
Yikes, shouldn’t be on SO when tired. Updated answer and fiddle to actually answer the OP’s question.