plentz / jquery-maskmoney

jQuery plugin to mask data entry in the input text in the form of money (currency).
https://plentz.github.io/jquery-maskmoney/
MIT License
964 stars 505 forks source link

Difficulty in changing values in an easy way #169

Open paaljoachim opened 9 years ago

paaljoachim commented 9 years ago

Hey

The WordPress plugin Give https://github.com/WordImpress/Give/issues/110#issuecomment-95345412 uses maskmoney for their custom donation field.

One thing that is difficult is clicking into the text field and changing a value.

Right now: Cursor blinks behind the 0.00 amount. Delete keyboard key does not work. Writing for instance 50 the amount changes to 0.50. Writing again 00 it then moves the amount forward to become 50.00. Just a minor hassle but just removing the 0.00 giving an open space for the user to write the amount would be better.

Could this be adjusted making the process easier?

DevinWalker commented 9 years ago

Here's a link of that in action: http://givewp.com/demo

gregoriokusowski commented 9 years ago

Hi guys.

The value 0.00 value is displayed with the cursor on the right side to make the user know that every typed number will be placed right there and 'moved' to the other point. This makes it simple to type values without bothering with decimal separators. It's currently a feature for applications where the user makes heavy use of the keyboard(tab... 123... tab... 456, and so on). Not showing the 0.00 value can force the user to type the decimal separator or just surprise it by applying the separator at some moment.

I think your request would be more acceptable like an option, like:

$("#field").maskMoney({userNeedsToWriteExactlyTheAmount: true}};

Can you guys open a PR with your suggestion?

DevinWalker commented 9 years ago

What about if the separator were automagically added? That would be the best option

plentz commented 9 years ago

@DevinWalker @paaljoachim well, I think that what you want is just this:

var field = $('#field');
field.on("blur", function(){
    field.maskMoney('mask');
}
DevinWalker commented 9 years ago

@plentz I just gave that a shot and couldn't get it working as expected. Nothing appear to happen on blur to the input.

$body.on( 'blur', '.give-donation-amount .give-text-input', function ( e ) {
//CODE HERE
//Fire up Mask Money
        $( this ).maskMoney( 'mask', {
            decimal  : give_global_vars.decimal_separator,
            thousands: give_global_vars.thousands_separator
        } );

});