-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Treat empty as zero #113
base: master
Are you sure you want to change the base?
Treat empty as zero #113
Conversation
- Added tests for blur event - Added tests for focus - Updated documentation
The "treatEmptyAsZero" can be set on submit form event too ? |
How is this different from: #110? Seems to be the same thing. |
Yes and No. The treatEmptyAsZero that I was thinking is just the zero, so in this test could be like this: test("allowZero: true - mask keeps default 0 value", function() {
var input = $("#input5").maskMoney();
input.trigger("mask");
equal(input.val(), "0.00", "0 value should be 0.00$ due to settings");
}); |
Nice. +1 |
Hey guys, thanks for looking. I needed to set this up for a personal project. Maybe I screwed up, but when I tried #110, it didn't give me the behavior I needed so I hacked it up myself and put it here in case it helps someone. With this PR, if you set It's the best of both worlds for us and so I thought I'd share. I do, however, think I prefer @jpSimkins terminology of Happy to rework it accordingly if you guys like the code/behavior, plan to merge it but need me to make any changes. Let me know! |
Great, this is what I was looking for! +1 |
After 3 years, today I discovered that I need this feature in the plugin. Should be merged. |
@edelbalso do you can resolve this conflict? |
This pull request adds a new option to the library:
treatEmptyAsZero
.Currently in this library, when focusing on an empty field, the masking library assumes the user intends "blank" to mean 0. I needed empty to mean "nothing" and allow the user to specify either "nothing" or 0 as the submitted value.
Here, setting
treatEmptyAsZero
tofalse
allows you to delete a0.00
masked value and allows the user to enter either a blank input or zero.