Support

Home Forums Event Espresso Premium Mandatory Fields Are Not Mandatory!

Mandatory Fields Are Not Mandatory!

Posted: March 27, 2013 at 7:09 pm


Amy Decker

March 27, 2013 at 7:09 pm

Hi,
I’m experiencing an issue that several other users have been able to resolve but I’m not having much luck.

The problem: Users can submit a registration form without entering a value for required fields.

Here is a link to my form.

I’ve narrowed it down to a theme issue. (Switching to TwentyTwelve fixes makes it work properly.) I’m using the latest version of WordPress-bootstrap by 320press. Several other threads have mentioned that this is a jquery issue and others have been able to resolve the problem by commenting some items out in the theme’s functions.php file.

I found the following block of code and commented out the entire thing in functions.php to see if it would make a difference but mandatory fields still aren’t enforced. (It just causes problems in other areas of the site.

<code>// enqueue javascript

function theme_js(){
  // wp_register_script('less', get_template_directory_uri().'/library/js/less-1.3.0.min.js');

  wp_deregister_script('jquery'); // initiate the function  
  wp_register_script('jquery', get_template_directory_uri().'/library/js/libs/jquery-1.7.1.min.js', false, '1.7.1');

  wp_register_script('bootstrap', get_template_directory_uri().'/library/js/bootstrap.min.js');
  // wp_register_script('bootstrap-button', get_template_directory_uri().'/library/js/bootstrap-button.js');
  // wp_register_script('bootstrap-carousel', get_template_directory_uri().'/library/js/bootstrap-carousel.js');
  // wp_register_script('bootstrap-collapse', get_template_directory_uri().'/library/js/bootstrap-collapse.js');
  // wp_register_script('bootstrap-dropdown', get_template_directory_uri().'/library/js/bootstrap-dropdown.js');
  // wp_register_script('bootstrap-modal', get_template_directory_uri().'/library/js/bootstrap-modal.js');
  // wp_register_script('bootstrap-popover', get_template_directory_uri().'/library/js/bootstrap-popover.js');
  // wp_register_script('bootstrap-scrollspy', get_template_directory_uri().'/library/js/bootstrap-scrollspy.js');
  // wp_register_script('bootstrap-tab', get_template_directory_uri().'/library/js/bootstrap-tab.js');
  // wp_register_script('bootstrap-tooltip', get_template_directory_uri().'/library/js/bootstrap-tooltip.js');
  // wp_register_script('bootstrap-transition', get_template_directory_uri().'/library/js/bootstrap-transition.js');
  // wp_register_script('bootstrap-typeahead', get_template_directory_uri().'/library/js/bootstrap-typeahead.js');

  wp_register_script('wpbs-scripts', get_template_directory_uri().'/library/js/scripts.js');
  wp_register_script('modernizr', get_template_directory_uri().'/library/js/modernizr.full.min.js');

  // wp_enqueue_script('less', array(''), '1.3.0', true);
  wp_enqueue_script('jquery');
  wp_enqueue_script('bootstrap', array('jQuery'), '1.1', true);
  // wp_enqueue_script('bootstrap-button', array('jQuery'), '1.1', true);
  // wp_enqueue_script('bootstrap-carousel', array('jQuery'), '1.1', true);
  // wp_enqueue_script('bootstrap-collapse', array('jQuery'), '1.1', true);
  // wp_enqueue_script('bootstrap-dropdown', array('jQuery'), '1.1', true);
  // wp_enqueue_script('bootstrap-modal', array('jQuery'), '1.1', true);
  // wp_enqueue_script('bootstrap-tooltip', array('jQuery'), '1.1', true);
  // wp_enqueue_script('bootstrap-popover', array('jQuery'), '1.1', true);
  // wp_enqueue_script('bootstrap-scrollspy', array('jQuery'), '1.1', true);
  // wp_enqueue_script('bootstrap-tab', array('jQuery'), '1.1', true);
  // wp_enqueue_script('bootstrap-transition', array('jQuery'), '1.1', true);
  // wp_enqueue_script('bootstrap-typeahead', array('jQuery'), '1.1', true);
  wp_enqueue_script('wpbs-scripts', array('jQuery'), '1.1', true);
  wp_enqueue_script('modernizr', array('jQuery'), '1.1', true);
}
add_action('wp_enqueue_scripts', 'theme_js');
</code>

Any suggestions?


Josh

  • Support Staff

March 27, 2013 at 7:25 pm

Hi Amy,

Only this part should be commented out:

wp_deregister_script(‘jquery’); // initiate the function
wp_register_script(‘jquery’, get_template_directory_uri().’/library/js/libs/jquery-1.7.1.min.js’, false, ‘1.7.1’);

That’s the part that’s removing and replacing the jQuery library that is included in WP with an older version.

Then, you’ll need to fix the JS errors that are caused by the theme. Once you fix one, there might be more that pop up because one error will prevent code further down on the web page from running. If you look at the page you linked to above in Firebug or in web inspector, you’ll likely see JavaScript errors that need to be fixed. They’ll point you to the exact line of code in the theme that needs to be fixed.


Amy Decker

March 27, 2013 at 8:24 pm

Josh,
Thanks for the quick reply. Commenting those 2 lines out just creates a ton of errors (I’m using firebug). It doesn’t fix the problem either, it just seems to break a bunch of stuff on the site. Currently, with the code as-is, there is only one minor error on the site that I don’t think is related to the issue (You can probably see it.)
I don’t know why they’re using jq 1.7.1 when 1.9 is out.
Any other ideas?


Amy Decker

March 27, 2013 at 8:31 pm

Perhaps if I knew what the actual conflict was. What would cause the theme-registered version of j-query to prevent the submit function from working properly?


Sidney Harrell

March 27, 2013 at 9:30 pm

The problem appears to be in http://cartoonadventurecamp.com/wp-content/themes/wordpress-bootstrap/library/js/scripts.js?ver=3.5.1 on line 36. That javascript error is preventing all the other javascript on the page that is loaded after that to not function, including the form validation script. It looks like wrapping that chunk of javascript in a no-conflict wrapper would fix the problem. http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers


Amy Decker

March 27, 2013 at 9:39 pm

Thanks Sidney, this helps a lot. I’ll let you know what happens.


Amy Decker

March 27, 2013 at 10:40 pm

Oh man, glad that crisis has been handled. And I learned something.
So, Sidney, you were right.
That document actually contained a bunch of functions using dollar signs.
As stated in the codex:

> …will either throw an error, or use the $ shortcut as assigned by other
> library.

I didn’t use the wrapper, I just replaced them with ‘jQuery’.

When I replaced the one on line 36, the error switched to the next function a few lines down. I went ahead and changed all of the $’s to jQuery in the whole sheet and there were no longer any errors on the site and the mandatory fields work now.

I should also note that these were the only changes I made. I didn’t need to make any changes to functions.php.

Thanks for the tip.

The support post ‘Mandatory Fields Are Not Mandatory!’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso