Revision: 14270
                            
                                                            
                                    
                                        
Updated Code
                                    
                                    
                                                    
                        at May 27, 2009 07:36 by loopdream
                            
                            Updated Code
jQuery.fn.moneyField = function(symbol) {
    return this.each(function() {
        $(this).focus(function(){
            if(!$(this).val()) $(this).attr('value', symbol);
        }).blur(function(){
            if($(this).val() == symbol) {
                $(this).attr('value', '');
            } else {
                s = $(this).val();
                s = $.numAddCommas(s); // Add commas to long digit strings - you will need to get a function to do this (find one on snipplr)
                $(this).attr('value', s);
                var hascur = s.indexOf(symbol);
                if(hascur) $(this).attr('value', symbol+s);
            }
        }).prev('label').click(function(){
            return false;
        });
    });
}
$(function(){
     $('input[name=money_field]').moneyField('£');
});
                                
                            Revision: 14269
                            
                                                            
                                    
                                        
Updated Code
                                    
                                    
                                                    
                        at May 27, 2009 07:36 by loopdream
                            
                            Updated Code
jQuery.fn.moneyField = function(symbol) {
    return this.each(function() {
        $(this).focus(function(){
            if(!$(this).val()) $(this).attr('value', symbol);
        }).blur(function(){
            if($(this).val() == symbol) {
                $(this).attr('value', '');
            } else {
                s = $(this).val();
                s = $.numAddCommas(s); // Add commas to long digit strings - you will need to get a function to do this (find one on snipplr)
                $(this).attr('value', s);
                var hascur = s.indexOf(symbol);
                if(hascur) $(this).attr('value', symbol+s);
            }
        }).prev('label').click(function(){
            return false;
        });
    });
}
$(function(){
     $('input[name=money_field]').moneyField('£');
});
                                
                            Revision: 14268
                            
                                                            
                                    
                                        
Updated Code
                                    
                                    
                                                    
                        at May 27, 2009 07:33 by loopdream
                            
                            Updated Code
jQuery.fn.moneyField = function(symbol) {
    return this.each(function() {
        $(this).focus(function(){
            if(!$(this).val()) $(this).attr('value', symbol);
        }).blur(function(){
            if($(this).val() == symbol) {
                $(this).attr('value', '');
            } else {
                s = $(this).val();
                s = $.globalEngine.numAddCommas(s);
                $(this).attr('value', s);
                var hascur = s.indexOf(symbol);
                if(hascur) $(this).attr('value', symbol+s);
            }
        }).prev('label').click(function(){
            return false;
        });
    });
}
$(function(){
     $('input[name=money_field]').moneyField('£');
});
                                
                            Revision: 14267
                            
                                                            
                                    
                                        
Updated Code
                                    
                                    
                                                    
                        at May 27, 2009 07:29 by loopdream
                            
                            Updated Code
jQuery.fn.moneyField = function(symbol) {
    return this.each(function() {
        $(this).focus(function(){
            if(!$(this).val()) $(this).attr('value', symbol);
        }).blur(function(){
            if($(this).val() == symbol) {
                $(this).attr('value', '');
            } else {
                s = $(this).val();
                s = $.globalEngine.numAddCommas(s);
                $(this).attr('value', s);
                var hascur = s.indexOf(symbol);
                if(hascur) $(this).attr('value', symbol+s);
            }
        }).prev('label').click(function(){
            return false;
        });
    });
}
                                
                            Revision: 14266
                            
                                                            
                                    
                                        
Initial Code
                                    
                                    
                                                            
                                    
                                        
Initial URL
                                    
                                    
                                
                                                            
                                    
                                        
Initial Description
                                    
                                    
                                
                                                            
                                    
                                        
Initial Title
                                    
                                    
                                                            
                                    
                                        
Initial Tags
                                    
                                    
                                                            
                                    
                                        
Initial Language
                                    
                                    
                                                    
                        at May 27, 2009 07:27 by loopdream
                            
                            Initial Code
<pre><code>jQuery.fn.moneyField = function(symbol) {
    return this.each(function() {
        $(this).focus(function(){
            if(!$(this).val()) $(this).attr('value', symbol);
        }).blur(function(){
            if($(this).val() == symbol) {
                $(this).attr('value', '');
            } else {
                s = $(this).val();
                s = $.globalEngine.numAddCommas(s);
                $(this).attr('value', s);
                var hascur = s.indexOf(symbol);
                if(hascur) $(this).attr('value', symbol+s);
            }
        }).prev('label').click(function(){
            return false;
        });
    });
}
</code></pre>
                                Initial URL
Initial Description
Initial Title
Toggle a money symbol to a form field on focus/blur - useful for cost data
Initial Tags
form, javascript, forms, jquery
Initial Language
JavaScript