AngularJs-Facing issue with ui-number-mask in Portuguese (Brazil) locale - javascript

My application locale is Portuguese (Brazil). In Brazil a dot (.) is used to separate thousands and comma(,) is used for decimal. Suppose user enters value 4.878 When user saves the data, it saves the correct value as entered in UI, but when next time page render it shows the round off value(i.e. 5 instead of 4.878). I am facing problem with numeric text box without decimal places,
<input class="inputbox" ng-model="value" ui-number-mask="0" />
If I set 2 decimal places for same textbox, then it will show/renders correct value always(i.e. 4.878,00):-
<input class="inputbox" ng-model="value" ui-number-mask="2" />
Any suggestion, why values are rounding off and how to fix this.

This sounds like a localization issue. Have you tried following this? https://docs.angularjs.org/guide/i18n

Related

Angular - Apply decimal pipe to an input

I want to apply decimal pipe on an input so the user can see comma separated numbers as he/she types. I have tried the ngx-mask but that only works if you type in the input. When you patch a value to the input it doesn't transform the value into decimal format.
Basically you can use ngModelChange when you value change you can use a pipe in your ngModel as below
<input [ngModel]="item.value | currency" (ngModelChange)="item.value=$event"
name="name" type="text" />
and more detail about it check this

How to input digits and symbols in Tizen web app

I'm trying to make input field, where I can enter IP address. If I use type="number" it is not possible to pick . symbol. But if I use type="text" there are some unnecessary keyboards are displayed, such as letters, voice input, emojis that I don't want to have. I want to have something like two pages with digits and symbols. Any suggestions?
index.html
<div class="ui-page" id="page-text-input">
<div class="ui-content text-input-content">
<input id="ip" name="ip" placeholder="IP" type="number" />
</div>
</div>
I verified your issue. I think this is not issue of keyboard or platform. Referring to https://developer.mozilla.org/pl/docs/Web/HTML/Element/Input#attributes
the input field type="number" doesn't fit to IP address. This type is dedicated for floating numbers.
Apart from the fact that there is one separator for decimals in the number, it can be a point or a comma depending on the location / region settings.
Only solution what I see that you add four input fields with type number for each IP number class or use some widget like spin widget.
Best regards,
Tomasz

Only accept quarterly floats

I would like an HTML input validated on integer # (hourly), #.5 (half hourly) and #.25 (quarter).
I tried using HTML input type='number', but this seems to be fixed integers only. Does anybody have any clue on how to make a system that restricts on quarters?
Guessing you haven't tried step attribute yet?
Also believe you want it to be a time input since you mention hourly
:invalid{
color: red
}
<input type="time" step="900"><br>
<input type="number" step="0.25">

HTML Field Type Input Number Only or Letter Only Without JavaScript

I create a form, where one field should only be filled with numbers.
I want that field can be filled only with numbers since entering input.
Like this example :
How Can I Use Javascript to Allow Only Numbers to Be Entered in a TextBox?
I've tried using Regex, but when I try to input is still able to enter letters.
<input type="number" min="2" pattern="^[0-9]" class="andi_input required-entry" name="amount" id="amount" required title='Only Number' />
I want it when input to field and not after click the Submit button and the message appear and inform that the field can only be filled with numbers.
I also try to add validate-number, but the result is the same.
How, without javascript, so that the field can only be filled with numbers or letters?
Whether for this kind of case have to use JavaScript or is there another way without JavaScript?
HTML 5 uses the type="number" so make sure that the browser that you are using is compatible. Check it out in action here.
You should check browser compatibility.
You're right with <input type="number" pattern="^[0-9]" />.
Your regex rule is :
^[0-9] :
^ assert position at start of the string
[0-9] match a single character present in the list below
(0-9 a single character in the range between 0 and 9)
You can check your regex here.
I use to use HTML5 Validation and jQuery one because IE is capricious most of the time.
UPDATE :
Without Javascript it's not possible to check pattern on real time. I suggest you to use a jQuery library like : http://www.jqueryscript.net/form/jQuery-Plugin-For-Formatting-User-Input-with-Specified-Pattern-formatter-js.html.
Here is a OneLiner:
<input type="number" onkeypress="return /[0-9]/i.test(event.key)">
or
<input type="text" onkeypress="return /[a-z]/i.test(event.key)">

Input Number Type Dollar Sign

I have a form with a line that asks for a dollar amount, however if the user puts a dollar sign in front of the number the form won't let it send because it is set to type="number".
Is there a way to let a user type in a dollar sign ($) in the type="number" and have the form send with no issue?
Code:
<label>Monthly Budget</label>
<input name="budget" type="number" placeholder="$400.00" required data-errormessage-value-missing="Uh oh, somethings wrong!" data-errormessage-type-mismatch="Uh oh, somethings wrong!">
Just denote the symbol before the input field so they don't add it again. Currency symbols aren't handled in code, they're added to the viewport for the users display on-the-fly.
<label>Monthly Budget</label>
<span class="input">$<input name="budget" type="number" placeholder="400.00" required data-errormessage-value-missing="Uh oh, somethings wrong!" data-errormessage-type-mismatch="Uh oh, somethings wrong!"></span>
Example
input type=number - Reference
The only way to let a user type in a dollar sign in a type="number" field and have the form send with no issue is to intercept (with JavaScript) user input with keyboard event handlers such as onkeyup, remove the dollar sign, and clear the status with setCustomValidity(''). This would require some care, since keyboard event handling (and recognizing which character was entered) varies across browsers. More importantly, it would result in poor usability: the user could type “$42” but would see the “$” vanish, and could get very confused.
Putting the dollar sign in front of the field is one way (not completely reliable) of avoiding the problem of a user-entered dollar sign (rather than solving it). Note that there are other issues with the code, too, such as the use of a specific amount of money as a placeholder (use value if you wish to set an initial value) and not allowing any cents, contrary to what 400.00 suggests. A better idea:
<label for="budget">Monthly Budget</label>
<input id="budget" name="budget" type="number"
placeholder="xxx.xx"
required
step="0.01"
title="Amount of money in numbers">
(If you wish to disallow cents, which would be sensible for a budget, omit the step attribute, defaulting it to 1, and omit the placeholder attribute, since there’s probably no suitable value for it.)
Alternatively, use input type="text" and a suitable pattern attribute, e.g.
<input id="budget" name="budget" type="text"
placeholder="xxx.xx"
required
title="Amount of money in numbers"
pattern="\$?(\d)+(\.\d\d)?">
(to allow cents but not require them). Note that this would make (on supporting browsers) input like 400.000 or 400.5 invalid, which is probably good. This approach would imply that in form data handling, you would need to deal with an optional leading “$”, which is normally simple of course.

Categories

Resources