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

From JReviews Documentation
Revision as of 18:06, 19 October 2010 by Jreviews (Talk | contribs)

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() {                
        jQuery("input#jr_website").click(function(){
            if (jQuery("input#jr_website").val() == '') {
                jQuery("input#jr_website").val('http://');
            }
        });                    
        jQuery("input#jr_website").blur(function(){
            if (jQuery("input#jr_website").val() == 'http://') {                
                jQuery("input#jr_website").val('');
            }            
        });            
    });
</script>


Change jr_website in the script above to the name of your website custom field.