381
Views
9
Comments
Solved
[Input Mask React] Removing right align
Question
inputmask-react
Reactive icon
Forge asset by João Barata

Hello,


Can anyone help me removing the rightAlign property for the decimals mask? I saw on the github documentation some information related to this but I couldn't manage to do it in a reactive application.


https://github.com/RobinHerbots/Inputmask#rightalign


Regards,

Bogdan

2024-01-18 12-42-28
Bogdan Boglea
Solution

Ok,


I think I found some solution for now, in the JS (inputmask_min.js) I modified the rightAlign: 0! with rightAlign: 1! wherever it occured and now text is left aligned.


I'm sure there are also other options to do it via a JS in the screen you are using this widget, but this does the job for me as well.


Regards,

Bogdan

2017-03-28 10-50-47
Paul.

Unfortunately this didn't work for me. Making the code changes listed above broke the script file.

I've come up with the following solution.
Add a class to the input element that forces the align left. This will overwrite the "style" element set by the InputMask componant:

Add Style Class on the element

"form-control alignLeft"

Style sheet CSS:

/* InputMaskCurrency */
.alignLeft, .form-control.alignLeft {
    text-align: left !important; 
}
2026-02-26 06-29-24
Rahul
 
MVP

Hi Bogdan,

when you see for decimal or number input in input mask by default property is 

text-align: right;

you can overwrite this

go to input property and set

style:"text-align: left"


Regards

Rahul Sahu

2022-10-18 07-32-49
Randall Jodache Chetty

Hi Rahul. 

Which property is this ? 

Or where can I find this property settings?


2024-01-18 12-42-28
Bogdan Boglea

Hi Rahul,


It still doesn't work like this. It seems the style is somehow applied using the javascript from this library. I would need something in the OnReady for the screen in order to set the rightAlign property to false (or !0 idk).


See below example from the javascript where this property is set


Regards,

Bogdan

2024-01-18 12-42-28
Bogdan Boglea
Solution

Ok,


I think I found some solution for now, in the JS (inputmask_min.js) I modified the rightAlign: 0! with rightAlign: 1! wherever it occured and now text is left aligned.


I'm sure there are also other options to do it via a JS in the screen you are using this widget, but this does the job for me as well.


Regards,

Bogdan

2017-03-28 10-50-47
Paul.

Unfortunately this didn't work for me. Making the code changes listed above broke the script file.

I've come up with the following solution.
Add a class to the input element that forces the align left. This will overwrite the "style" element set by the InputMask componant:

Add Style Class on the element

"form-control alignLeft"

Style sheet CSS:

/* InputMaskCurrency */
.alignLeft, .form-control.alignLeft {
    text-align: left !important; 
}
2020-10-08 19-51-35
João Barata
Staff

Hi, thanks for bringing this to my attention,

I'll try to create a new version that has more options for you to customize the behavior of the input mask.

Regards,

2017-03-28 10-50-47
Paul.

This would be very helpful.
We run into the same problem where this component is overwriting align:left on the input element.

2025-09-23 15-26-52
Joana Salgueiro
Staff

Hello,

If you don't want to customize the plugin you also can solve this using JS on the screen. You can do something like this in the OnReady function of your screen or web block:


Regards,

Joana Salgueiro

2022-10-06 10-27-22
Ahtisham Ul Haq

I have just created a JS script that you can use in the on ready Client action that capture all the inputs In which you want the text to be aligned to left. you can follow the below steps : 

  1. First you can assign any text (In my case It was "PercentageInput") to the Style classes of the Input.
  2. Then you can drag and drop the Java Script node to the flow to the on ready client action and copy the below JS script in the JS node and paste it there and publish. 
    function alignPercentageInputs(root) {  var percentageInputs = (root || document).querySelectorAll('input.PercentageInput');  percentageInputs.forEach(function(Input) {    Input.style.textAlign = "left";  });}
    // Initial pass on page loadalignPercentageInputs(document);
    // Observe DOM changes to catch newly inserted inputs (e.g., after Ajax refreshes)var observer = new MutationObserver(function(mutations) {  mutations.forEach(function(mutation) {    mutation.addedNodes.forEach(function(node) {      if (node.nodeType === 1) { // ELEMENT_NODE        // Align if the node itself is an input or contains inputs        if (node.matches && node.matches('input.PercentageInput')) {          node.style.textAlign = "left";        } else {          alignPercentageInputs(node);        }      }    });  });});
    observer.observe(document.body, { childList: true, subtree: true }); 

I hope it will solve the issue, and it is optimized if you have multiple Inputs and some are rendering after some conditions or later stages of the screen. If you have any more issues or question do ping me anytime.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.