View difference between Paste ID: 3T8PZ69k and J2rnQRc2
SHOW: | | - or go back to the newest paste.
1
<?php
2
}
3
4
/* We use jQuery to read the placeholder value and inject it to its field */
5
6
add_action('gform_enqueue_scripts',"my_gform_enqueue_scripts", 10, 2);
7
8
function my_gform_enqueue_scripts($form, $is_ajax=false){
9
global $is_IE;
10
11
?>
12
<script>
13
14
jQuery(function(){
15
<?php
16
17
/* Go through each one of the form fields */
18
19
foreach($form['fields'] as $i=>$field){
20
21
/* Check if the field has an assigned placeholder */
22
23
if(isset($field['placeholder']) && !empty($field['placeholder']) && !$is_IE){
24
25
/* If a placeholder text exists, inject it as a new property to the field using jQuery */
26
27
?>
28
29
30
31
jQuery("#input_<?php echo $form['id']?>_<?php echo $field['id']?>").attr('placeholder',"<?php echo $field['placeholder']?>");
32
33
34
<?php
35
}
36
elseif($is_IE) { ?>
37
38-
jQuery("#input_<?php echo $form['id']?>_<?php echo $field['id']?>").attr('value',"<?php echo $field['placeholder']?>");
38+
jQuery("#input_<?php echo $form['id']?>_<?php echo $field['id']?>").attr('value',"<?php echo $field['placeholder']?>")
39
.attr('onblur',"if(this.value == '') {this.value = '<?php echo $field['placeholder']?>';}")
40
.attr('onfocus',"if(this.value == '<?php echo $field['placeholder']?>') {this.value = '';}")
41
42
43
<?php
44
}
45
}
46
?>
47
});
48
</script>
49
<?php
50
}
51
?>