Im building a Jquery form validation plugin. my concern is that my plugin does not return the object for chaining purpose. but rather it returns an array. the array is one of the two
- array1 contains all the required field names which are not filled in. but if all the required fields are filled in then this is ignored.
- array开发者_如何学编程2 will be returned only if value inside form input element is not matching(regex). other wise a true is returned if all the required fields are filled in and the data are correct in the form input elements and the form will be submitted.
So any suggestion please, if you think this is bad, because the plugin should return the object for chaining purpose. or if you think im doing this its all ok. thanks for your help in advance
Make your plugin require a callback as a parameter. Instead of returning your array, you can pass it to the callback. This will get the data out, but let you still return the object as well.
精彩评论