Skip to content
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

TypeError: Cannot read properties of null (reading 'charAt') at m.onBeforeMask #2789

Closed
sinhnv1991 opened this issue May 11, 2024 · 3 comments
Assignees

Comments

@sinhnv1991
Copy link

Please add new line e = e === null ? "" : e; on file inputmask.js at function onBeforeMask: function(e, t) {...
line 1812, because if value to input from database is null, null is not string can't reading charAt
onBeforeMask: function(e, t) {
var n = t.radixPoint || ",";
//please add line
e = e === null ? "" : e;//check only null because keep 0 value display to input
}
example mask currency will error

  • vesion: lasted
@Techn1c4l
Copy link

You shouldn't set values to null in any input or textarea. If you are receiving a null value from an external source, it's your job to convert it to a proper input element representation, e.g. converting null to an empty string or 0.

I usually check the initial value of my components which use Inputmask if it's valid. If it's not valid (empty string, null, undefined), I would set it to a default value like 0 or to a minimum value.

@RobinHerbots RobinHerbots self-assigned this May 14, 2024
@RobinHerbots
Copy link
Owner

@sinhnv1991, @Techn1c4l ,

I can agree with what @Techn1c4l says, but on the other hand should the mask not fail if some faulty value is passed, but it should just ignore it.

@sinhnv1991
Copy link
Author

sinhnv1991 commented May 15, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants