SHARE
TWEET

Untitled

KenLStark Oct 29th, 2012 236 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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']?>")
  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. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top