Skip to content

Commit 872577b

Browse files
authored
Create gw-force-numeric-keyboard-on-mobile.php
1 parent d826b08 commit 872577b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* Gravity Wiz // Gravity Forms // Force Numeric Keyboard for Number Fields on Mobile
4+
* https://gravitywiz.com/
5+
*
6+
* This snippet forces the numeric keyboard for Number fields on mobile devices by updating the "type" attribute of the
7+
* input to "tel" instead of "number". If you find there are any drawbacks to this approach, let us know!
8+
*/
9+
add_filter( 'gform_field_content', function( $content, $field ) {
10+
if ( $field->get_input_type() === 'number' ) {
11+
$content = str_replace( 'type=\'number\'', 'type=\'tel\'', $content );
12+
}
13+
return $content;
14+
}, 10, 2 );

0 commit comments

Comments
 (0)