www.webdeveloper.com
Results 1 to 3 of 3

Thread: Clearing form fields upon focus (IE8 problem)

  1. #1
    Join Date
    Aug 2005
    Location
    Auckland, NZ
    Posts
    37

    Clearing form fields upon focus (IE8 problem)

    hey guys, i have the following code that will clear a default value in a form field upon focus and return it upon blur. now this works in chrome, ff but not on my IE8 (Windows XP). however... it does work on same browser on the website jsfiddle.net - this is doing my head in and was wondering if anyone can point me in the right direction for fixing...

    Code:
    <script type="application/javascript">
    	$(document).ready(function() {
    		
    		// replaces default values in forms
    		$('.default-value').each(function() {
    			var default_value = this.value;
    			$(this).bind('focus', function() {
    				if(this.value == default_value) {
    					this.value = '';
    				}
    			});
    			$(this).bind('blur', function() {
    				if(this.value == '') {
    					this.value = default_value;
    				}
    			});
    		});
    		
    	});
    </script>
    
    <input type="text" name="filter_name" class="default-value" value="Keyword search..." />
    also, this is the jquery script i am using...

    Code:
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    Last edited by NZSolutions; 04-12-2012 at 06:19 PM.
    Little Giant
    Print + Internet Design
    http://www.littlegiant.co.nz

  2. #2
    Join Date
    Aug 2005
    Location
    Auckland, NZ
    Posts
    37
    This is a test page I have of the function also...

    http://preview.allaboutpromo.co.nz/test.php
    Little Giant
    Print + Internet Design
    http://www.littlegiant.co.nz

  3. #3
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    Perplexing. It doesn't work in IE7, either. I'm trying to find the issue, but am currently at a loss.

    UPDATE:
    Did some Googling and found this. Have not tested it. Hopefully this will work?
    http://snipplr.com/view/15360/

    Here is another one, same site:
    http://snipplr.com/view/55558/
    Last edited by WolfShade; 04-14-2012 at 12:13 PM.
    |||||
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long

    ^_^

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles