Auto-prepend HTTPS to URLs
Experimental Snippet 🧪
Auto-prepend “https://” to URLs in Website fields.
Code
Filename: gw-auto-prepend-https.js
/**
* Gravity Wiz // Gravity Forms // Auto-prepend HTTPS to URLs
* https://gravitywiz.com/
*
* Experimental Snippet 🧪
*
* Auto-prepend "https://" to URLs in Website fields.
*/
// Update "1" to your field ID.
$( '#input_GFFORMID_1' )
.on( 'focus', function() {
if ( $( this ).val() === '' ) {
$( this ).val( 'https://' );
}
} )
.on( 'keyup', function() {
if ( $( this ).val() === 'https:/' ) {
$( this ).val( 'https://' );
} else if ( $( this ).val().indexOf( 'https://' ) !== 0 ) {
$( this ).val( 'https://' + $( this ).val() );
}
} );