Well, I found a temporary fix. I am running the code only on the web page i need it to run by selecting its class, as follows:
- if (jQuery('.page-id-26801').length > 0) {
- jQuery( "#featuredImage" ).rules( "add", {
- required: true,
- messages: {
- required: "Insert message here"
- }
- });
- }
I found an error in jquery.validate.min.js
- Uncaught TypeError: Cannot read property 'form' of undefined
So, I am guessing that because I have the form in one page only (submit-post.php) and the validate plugin is running on the whole site. The error is caused by not being able to find the property form in the other pages of my site.
Does this mean, I must run the validate plugin only where needed?