-
AuthorPosts
-
October 25, 2014 at 3:50 pm #340968
HI there, I need to add an extra hook to the functions.php but every time I click save the screen goes blank.
Here’s the code I need to add:
<?php/**
* If you need to make some of the GravityView search fields required before search is submited
* – add as many lines as you need to define which fields are required
* e.g. -> jQuery(‘#gv_search_XYZZ’).prop(‘required’, true );
*
* Add this gist to your theme functions.php
*
*/add_action(‘gravityview_after’, ‘my_theme_make_search_fields_required’ );
function my_theme_make_search_fields_required() {
?>
<script>
//define here the search fields that are required
jQuery(‘#gv_search_2247’).prop(‘required’, true );// validation magic
jQuery(‘form.gv-widget-search’).submit( function(e) {
e.stopPropagation();
var isValid = true;
jQuery(‘.gv-widget-search input:required’).each( function(){
if( jQuery(this).val() === ” ) {
isValid = false;
}
});
return isValid;
});
</script>
<?php
}What I’m doing wrong?
Please let me know how to fix it.October 25, 2014 at 5:56 pm #340992Hey Jorge!
Your website doesn’t load on my end, have you checked your PHP error log for some clue?
Best regards,
JosueOctober 25, 2014 at 6:07 pm #340994Hi Josue, now it loads correctly. Can you check again please.
October 25, 2014 at 6:19 pm #340998Hi!
Please re-check the URL:
http://www.downforeveryoneorjustme.com/http://www.burorento.com.mx/servicioBest regards,
JosueOctober 25, 2014 at 6:32 pm #341001This reply has been marked as private.October 25, 2014 at 6:38 pm #341003Hi!
Try putting the code without the “<?php”. Also i’d recommend using this plugin to store custom functions like that, separated from the theme source.
Best regards,
Josue -
AuthorPosts
- You must be logged in to reply to this topic.
