• Resolved theresacambria

    (@theresacambria)


    I applied the following code to the textarea.php file and the onfocus/onblur functionality works but now the field only allows one line of text in the middle of the box, instead of multiple lines starting at the top of the box, as if it were a text input instead of textarea input.

    Here is the code I used plus a little of what comes just before it and just after for reference:

    if ( ! empty( $content ) )
    			$value = $content;
    	}
    
    // Default value disappears onfocus, reappears onblur if still empty
    $html = '<input type="textarea" name="' . $name . '" value="' . esc_attr( $value ) . '"' . $atts . 'onfocus="if(this.value==\'';
    $html = $html . esc_attr( $value ) . '\') this.value=\'\';" onblur="if(this.value==\'\') this.value=\'' . esc_attr( $value ) . '\';" </textarea>';
    
    	$validation_error = '';
    	if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) )

    Any help would be much appreciated!

    http://wordpress.org/extend/plugins/contact-form-7/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    <input type="textarea" ?

    It should be <textarea

    Thread Starter theresacambria

    (@theresacambria)

    Thank you so much! That fixed the problem 🙂 Great plugin, by the way.

    For anyone reading this in the future – the code I posted before, together with the correction, worked perfectly in Firefox 3.6.8 but in IE7 and IE8 the default value was acting a bit wacky. On page load it was showing all the source code that follows the contact form as the default value but if I deleted it and clicked out of the box the correct value would show up in its place. I replaced the previous custom code with this (provided by vmercader):

    $html = '<textarea name="' . $name . '"' . $atts . ' onblur="if (this.value == \'\') {this.value = \'' . esc_html( $value ) . '\';}" onfocus="if (this.value == \'' . esc_html( $value ) . '\') {this.value = \'\';}">' . esc_html( $value ) . '</textarea>';

    Now the textarea functions perfectly across the board.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Contact Form 7] textarea input is wrongly functioning as text input’ is closed to new replies.