Masked input value is sent to server unmasked

Masked input value is sent to server unmasked

sergey88sergey88 Posts: 6Questions: 1Answers: 0

Title pretty much sums up the issue.
Let's say i have a field in the editor:
{ label: 'cargoWeight', name: 'cargoWeight', type: 'mask', mask: '0999999.9999', }

After i enter 10.10 in the field and send the data, 10.10 is sent as 1010 - without the dot.
How do i fix that?

This question has an accepted answers - jump to answer

Answers

  • Bindrid2Bindrid2 Posts: 79Questions: 4Answers: 12
    Answer ✓

    I do not care much for the behavior of mask so I created my own plug-in to deal with numbers.

    here is a rough draft of it https://github.com/bindrid/DataTable-Plug-ins/blob/master/Editor%20Numeric%20Field

  • sergey88sergey88 Posts: 6Questions: 1Answers: 0

    @Bindrid2 , hey, that's pretty good.
    I'll just disallow commas, just this once.
    Thanks!

  • allanallan Posts: 65,815Questions: 1Answers: 10,950 Site admin

    Yeah - that's superb. Nice one!

    Allan

  • belubelu Posts: 38Questions: 14Answers: 0

    Is there any way to get the masked value with the editor.maks.js ?
    thanks!

  • allanallan Posts: 65,815Questions: 1Answers: 10,950 Site admin

    Yes it appears it is possible from their documentation.

    So in Editor you could do:

    editor.field('myField').input().masked(...);
    

    To be honest I don't understand why you would need to pass something into masked() since I would have thought it would just read from the input element, but that would be a question for the Masked input folks.

    Allan

This discussion has been closed.