Quantcast
Channel: WordPress.org Forums » [Contact Form 7] Support
Viewing all articles
Browse latest Browse all 49500

Jonathan on "[Plugin: Contact Form 7] Placeholder (watermark) not visible under older browser"

$
0
0

Here's a working solution for all none HTML5 Browsers. Testing in Chrome 27, IE7, IE8, IE9, IE10, Firefox 21, Safari 5.1.7, All working as they should with/without HTML5.

I've adapted on a solution from Pryley here

// Check if browser supports HTML5 input placeholder
function supports_input_placeholder() {
	var i = document.createElement('input');
	return 'placeholder' in i;
}

// Change input text on focus
if (!supports_input_placeholder()) {
	jQuery('.wpcf7-text').each(function() {
    	var self = jQuery(this);
		var value = jQuery.trim(self.val());
		if(value == '') self.val(self.attr('placeholder'));
    });
	jQuery('.wpcf7-text').focus(function(){
		var self = jQuery(this);
		if (self.val() == self.attr('placeholder')) self.val('');
	}).blur(function(){
		var self = jQuery(this);
		var value = jQuery.trim(self.val());
		if(value == '') self.val(self.attr('placeholder'));
	});
}

Viewing all articles
Browse latest Browse all 49500

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>