Buy Now
Sign in

data-inputmask percent

Carmiel , October 25 2017
C
Carmiel

Hi dears,
I try to do something than should be simple, add a symbol to a input field (value come from database).
I added this in extra parameters, but it doesn't work

				readonly=readonly
data-inputmask:'mask': '99 %'


I guess % could be € ou $ for money symbol

Any suggestion for me ?
Thank's a lot

GreyHead

Hi Carmiel,

The format for the Extra parameters uses = not : for the first one and the constant values need to be escaped (please see the InputMask docs here).

				data-inputmask='mask': '99\\ %'
				

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

C
Carmiel

Thank's for your answer.
But unfortunatly it doesn't work
Regards

GreyHead

Hi Carmiel,

Apologies, I managed to put the = sign in the wrong place. I have updated my post.

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

C
Carmiel

Sorry, it doesn't work and now it is left aligned.
here is the code generated

				<input readonly="readonly=&quot;readonly=readonly&quot;" data-inputmask="mask" ="="" '99\\="" %'"="" data-validationrules="{&quot;identifier&quot;:&quot;rfemmes-main&quot;,&quot;optional&quot;:false,&quot;rules&quot;:[{&quot;type&quot;:&quot;maxLength[50]&quot;,&quot;prompt&quot;:&quot;% Femmes&quot;}]}" data-validate="rfemmes-main" data-events="[]" placeholder="" name="rfemmes" id="rfemmes" value="71" type="text">
				

C
Carmiel

I notice that the : is subsitued by =

C
Carmiel

Good morning Bob,
I try to understand what I need to do with files of github on Joomla, but I don't understand how to install or where to copy files.
And I don't find really help in readme files.
Thank's
Roland

GreyHead

Hi Roland,

You don't need to do anything with GitHub except read the help files.

It looks as though the code you have posted is gaining a lot of extra quotes from somewhere. You have

				data-inputmask="mask" ="="" '99\\="" %'"=""
				
instead of
				data-inputmask='mask': '99\\ %'
				
Does your server have Magic Quotes enabled in the PHP settings - that might explain the changes?

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

C
Carmiel

Hi Bob,
doesn't work more
Magic Quotes is disabled

it give, I notice &quot; instead of '

				
<input readonly="readonly=&quot;readonly=readonly&quot;" data-inputmask="mask" ="="" '99\\="" %'"="" ="data-inputmask="&quot;mask&quot;" =&quot;="&quot;&quot;" %'&quot;="&quot;&quot;&quot;" data-events="[]" placeholder="" name="rhommes" id="rhommes" value="29" type="text">
				


And the console give this error
				
VM5116:1 Uncaught SyntaxError: Unexpected token m in JSON at position 1
at JSON.parse (<anonymous>)
at j (75d6a6302447d65de07c0cdd927c5719.js:778)
at HTMLInputElement.<anonymous> (75d6a6302447d65de07c0cdd927c5719.js:778)
at Function.each (jquery.min.js?93a13d3ef80fba9824a91ca88600150c:2)
at e.mask (75d6a6302447d65de07c0cdd927c5719.js:778)
at HTMLInputElement.<anonymous> (75d6a6302447d65de07c0cdd927c5719.js:779)
at Function.each (jquery.min.js?93a13d3ef80fba9824a91ca88600150c:2)
at a.fn.init.each (jquery.min.js?93a13d3ef80fba9824a91ca88600150c:2)
at a.fn.init.a.fn.inputmask.a.fn.inputmask (75d6a6302447d65de07c0cdd927c5719.js:779)
at Object.$.G2.forms.ready (75d6a6302447d65de07c0cdd927c5719.js:760)

GreyHead

Hi Roland,

Hmmm . . . something is adding those quotes and HTML entities - when I test there is no problem and the mask works correctly.

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

C
Carmiel

Hi Bob,
thank's for your answer, I will make a copy of the site and test to stop pluggin one after one.
I guess it is something round jquery

Thank's again for you help
have a nice day (or evening depend where you are ;-)

C
Carmiel

Hi Bob,
I solved the problem (almost)
at the end I added this and important Mask in Validation tab is at None

				readonly=readonly
style:text-align: right;
data-inputmask:'mask' : '99\\ %'


I added right align because without Integer Mask it align numbers at left

So why almost ?
because when the percentage is less than 10% it give _x %
So, if there is a possibility to choose mask, something like

readonly=readonly
style:text-align: right;

				
if ({var:read_data9.TdB.rmoinsde60} < 10) 
{data-inputmask:'mask' : '9\\ %' } else {data-inputmask:'mask' : '99 \\%' }


this example doesn't work

any suggestion ?

Thank's a lot

GreyHead

Hi Carmiel,

From the docs:

Optional masks
It is possible to define some parts in the mask as optional. This is done by using [ ].

Example: $('#test').inputmask('(99) 9999[9]-9999');

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

C
Carmiel

Hi Bob,
I tried to understand what to do but no success. I read the help, but not clear for me. I tried different syntax, but no valid result.
The field is called rmoinsde60 and data fetched from database by {var:read_data9.TdB.rmoinsde60}
inputmask without condition is : data-inputmask:'mask' : '99\\ %'

So what should be the line to test the condition ?

Thank's for your help