forked from gravitywiz/snippet-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
849b916
commit f08ccad
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Gravity Wiz // Gravity Forms // Use HTML5 Datepicker | ||
* | ||
* Some users, especially on mobile, may prefer their browser's native datepicker. This snippet will | ||
* convert date fields to use the native datepicker if the visitor is on a mobile device. Optionally, you can | ||
* have the date fields converted for all users (including desktop). | ||
* | ||
* Instructions: | ||
* 1. Install our free Custom JavaScript for Gravity Forms plugin. | ||
* Download the plugin here: https://gravitywiz.com/gravity-forms-custom-javascript/ | ||
* 2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin. | ||
*/ | ||
|
||
var onlyConvertOnMobile = true; // Change to false if you wish for all devices to use HTML5 datepicker | ||
|
||
var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); | ||
|
||
if ( isMobile || onlyConvertOnMobile === false ) { | ||
jQuery.fn.datepicker = function() {}; | ||
|
||
jQuery( '#gform_fields_GFFORMID .ginput_container_date input' ) | ||
.attr( 'type', 'date' ); | ||
} |