How to set default website custom field value to http://

From JReviews Documentation
Jump to: navigation, search

The website custom field requires a full url to be entered, including http://.

If users enter urls without it, the validation will fail.

To prevent this, you can use Javascript to automatically add http:// as the field value.

To do that, edit this file:

  • \com_jreviews\jreviews\views\themes\default\listings\create_form.thtml


Find this code in the file:

<?php 
/********************************************************************************** *                                 EDIT HTML BELOW THIS LINE **********************************************************************************/
?>


and paste this Javascript code below it:

<script type="text/javascript">
  jQuery(function() {
        var websiteFields = ['jr_linka', 'jr_linkb']; // names of website custom fields
        jQuery.each(websiteFields, function(i, val){
            var el = jQuery("input."+val);
            el.click(function(){
                if (el.val() == '') {
                    el.val('http://');
                }
            });                    
            el.blur(function(){
                if (el.val() == 'http://') {
                    el.val('');
                }            
            });    
        });          
  });
</script>


Enter the names of your website custom fields into the websiteFields array.