Support

Home Forums Event Espresso Premium Form validation with [SINGLEEVENT]

Form validation with [SINGLEEVENT]

Posted: September 25, 2013 at 5:12 pm

Viewing 8 reply threads


Brittany Stone

September 25, 2013 at 5:12 pm

Form validation is not working when I use the [SINGLEEVENT] shortcode in a widget.
It allows blank fields to be inputted and submitted.

http://stage.striptrips.com/itinerary/

Is the page that is experiencing the problems. (everything is in test mode)


Dean

September 26, 2013 at 2:13 am

Hi Brittany,

Yep that isn’t working. I cannot see an easy workaround right now so I will raise a ticket to get that looked into.


Dean

September 26, 2013 at 2:31 am

Sorry I do have a workaround, it is a bit rough but should get the job done. Add it to your themes functions.php file and change XXXXXX to your site url.

function ee_val() {

wp_enqueue_script('jquery');
wp_enqueue_script("espresso-validate", "http://www.XXXXXXXX.com/wp-content/plugins/event-espresso/scripts/jquery.validate.min.js", array("jquery"), "1.8.1", true);	

?>
<script type="text/javascript">
jQuery(".btn_event_form_submit").click(function() { 
	//Registration form validation
	jQuery("#registration_form").validate();
});

</script>



<?php

}
add_action('wp_footer', 'ee_val');


Brittany Stone

September 26, 2013 at 10:37 am

Looks like you have some syntax errors, so I went and corrected them but it still doesn’t seem to work.

Here is the code with my corrections:
[code language=”php”]
function ee_val() {
wp_enqueue_script(‘jquery’);
wp_enqueue_script(“espresso-validate”, “http://striptrips.wp/wp-content/plugins/event-espresso/scripts/jquery.validate.min.js&quot“, array(“jquery”), “1.8.1”, true);
?>
<script type=”text/javascript”>
jQuery(“.btn_event_form_submit”).click(function() {
//Registration form validation
jQuery(“#registration_form”).validate();
});
</script>
<?php
}
add_action(‘wp_footer’, ‘ee_val’);
[/code]


Brittany Stone

September 26, 2013 at 10:39 am

Alright, I am so very confused. Now I understand why the code had errors, its getting changed when posted to the forum.
Is there any other way you can send me the original code?


Josh

  • Support Staff

September 26, 2013 at 1:08 pm

Hi Brittany,

Can you try this instead? If you open up /event-espresso/includes/shortcodes.php you’ll find the very first shortcode listed is [SINGLEEVENT]. Just below where it says on line 20:

global $load_espresso_scripts;
$load_espresso_scripts = true; //This tells the plugin to load the required scripts

You can add these two lines:

wp_enqueue_script('jquery.validate.js', (EVENT_ESPRESSO_PLUGINFULLURL . "scripts/jquery.validate.min.js"), array('jquery'), '1.8.1', TRUE);
wp_enqueue_script('validation', (EVENT_ESPRESSO_PLUGINFULLURL . "scripts/validation.js"), array('jquery.validate.js'), EVENT_ESPRESSO_VERSION, TRUE);

and save the file.

This will ensure that the validation scripts load where ever you have the [SINGLEEVENT] shortcode.


Brittany Stone

September 26, 2013 at 1:24 pm

Should I use the custom code plugin?


Josh

  • Support Staff

September 26, 2013 at 1:57 pm

You could use the custom files add-on by copying over the entire shortcode function from shortcodes.php into custom_functions.php and modifying it there. You could also make the change in the core plugin.


Brittany Stone

September 27, 2013 at 10:47 am

I copied over the code, inserted the code you gave me, and it works! Thanks for your help!

Viewing 8 reply threads

The support post ‘Form validation with [SINGLEEVENT]’ 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