views:

269

answers:

2

I've got a table an input box that has a money input mask on it. I haven't had any problems with it yet, but now it doesn't seem to be working properly and I can't get anything to alert from it.

All of this is an internet explorer problem. Works fine in FireFox.

In firefox the mask works right as it only allows numbers and at a fixed format, but in ie, the format, or mask, is shown correctly when you're on focus, but as once you begin typing, the characters are being appended, rather than in place of the mask. It also is allowing non numeric characters. I've tried alerting in IE, but that also is not working. I can't find anything on this issue through google..

You'll have a better understanding of what it's doing if you check in firefox and then IE. It's the less advance cell at the bottom. or just append #less to the url.

I'll provide any code relevant to this..Though, I'm not getting any errors.

Code:


<td class="totals<cfif r EQ 1>1</cfif>"><cfif r EQ 1>Total<cfelse><input type="text" <cfif labels[r] EQ "Less Advance(if applicable)">id="less"</cfif><cfif labels[r] EQ "Net Due Employee">id="net"</cfif>id="totals" class="ttlR#r# total<cfif labels[r] EQ "Grand Total"> grandTot</cfif>" name="totals#r#" readonly="readonly" /></cfif></td>



$('#less').removeAttr("readonly").css("background-color", "none").css("text-align", "right").maskMoney({symbol: ""});

$('#less').keyup(function(){
    $('#net').val(Number($('.grandTot').val() - $('#less').val()).toFixed(2));
    alert($('#less').val());
});
//Get value of net total if page is refreshed.//
if($('#less').val() != "" || $('#less').val() != " "){
    $('#net').val(Number($('.grandTot').val() - $('#less').val()).toFixed(2));
}
+1  A: 

It doesn't look like the mask is being applied at all in IE. Which plugin are you using for the masking?

EDIT

I'm testing with IE 7.0.5730.13 and the mask doesn't work at all. Focusing-on and typing-in the <input> yields no special functionality, but it does throw an error

Line:  13
Char:  12949
Error: Invalid property value.
Code:  0

Have you tried debugging this with Firebug lite?

Also, you need to up your discipline with utilizing jQuery efficiently. Reuse Reuse Reuse!

var $less     = $('#less')
  , $net      = $('#net')
  , $grandTot = $('#totals .grandTot')
;

$less
  .removeAttr( "readonly" )
  .css( "background-color", "none" )
  .css( "text-align", "right" )
  .maskMoney( {symbol: ""} )
;

$net.bind( 'update-total', function()
{
  $net.val( Number( parseFloat( $grandTot.val() ) - parseFloat( $less.val() ) ).toFixed( 2 ) );
} );

$less.keyup(function()
{
  $net.trigger( 'update-total' );
  alert( $less.val() );
});

//Get value of net total if page is refreshed.//
if ( $less.val() != "" || $less.val() != " " )
{
  $net.trigger( 'update-total' );
}
Peter Bailey
The plugin im using is: http://plugins.jquery.com/project/maskinputmoney Also, I know my jquery isn't 100% perfect, but it's not bad at all. I've actually read that article before too. For now though, I just want to focus on this. The mask "appears" to be working because you can see the "0.00" when you focus on the input, but then it all breaks from there when you start typing ( im checking in IE 7. There may be other problems ie6 or ie8 ). Thinking it has to do with the keyup
Michael Stone
Added to my answer
Peter Bailey
Yes, i noticed that error when i turned on error reporting through the internet options. Not sure at all what that is. Are the other masks working properly for you? Within the tables body there are the same masks that show no defects. That is what stumps me.
Michael Stone
+1  A: 

$('#less').keyup(function(){ $('#net').val(Number($('.grandTot').val() - $('#less').val()).toFixed(2)); alert($('#less').val()); });

You are quite likely overwriting your masking function with this. Take out everything but masking and then see if your masking works. If so then it is one of your additional functions overwriting the masking changes to the input box.

Russell Steen
Great analysis. I've done this and I've got the mask working properly. Now it's just slowing piecing them together.
Michael Stone