Is there any way to define an `<input>`

that shows a keyboard input that only allows numbers and the decimal point (or comma for international users)?

`<input type='tel'>`

shows phone crap I don't need, and no decimal point

`<input type='number' pattern='[0-9]*'>`

shows all numbers, but no decimal point

What can I do to get the input I need?

If you were doing this in a bona fide iOS app, you could probably add buttons of your own on top of the keyboard, based on this question, which is about the accessory view but the same process would work.

Otherwise, IamChuckB is right and the five keyboard types given in the Apple Developer's Library are exhaustive.

You can try this attribute to your type="number" field:

```
pattern="\d+(\.\d*)?"
```

this will allow only digits with/without a decimal point and the floating numbers on the right.

Please see my project of the cross-browser filter of value of the text input element on your web page using JavaScript language: Input Key Filter . You can filter the value as an integer number, a float number, or write a custom filter, such as a phone number filter. See an example of code of input a float number

```
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Input Key Filter Test</title>
<meta name="author" content="Andrej Hristoliubov anhr@mail.ru">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<!-- For compatibility of IE browser with audio element in the beep() function.
https://www.modern.ie/en-us/performance/how-to-use-x-ua-compatible -->
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<link rel="stylesheet" href="https://rawgit.com/anhr/InputKeyFilter/master/InputKeyFilter.css" type="text/css">
<script type="text/javascript" src="https://rawgit.com/anhr/InputKeyFilter/master/Common.js"></script>
<script type="text/javascript" src="https://rawgit.com/anhr/InputKeyFilter/master/InputKeyFilter.js"></script>
</head>
<body>
<h1>Float field</h1>
Float field:
<input id="Float"
onchange="javascript: onChangeFloat(this)"
onblur="inputKeyFilter.isNaN(parseFloat(this.value), this);"
/>
<script>
CreateFloatFilter("Float");
function onChangeFloat(input){
inputKeyFilter.RemoveMyTooltip();
var elementNewFloat = document.getElementById("NewFloat");
var float = inputKeyFilter.parseFloat(input.value);
if(inputKeyFilter.isNaN(float, input)){
elementNewFloat.innerHTML = "";
return;
}
elementNewFloat.innerHTML = float + " or localized value: " + float.toLocaleString();
}
</script>
New float: <span id="NewFloat"></span>
</body>
</html>
```

Also see my page "Float field:" of the example of the input key filter

=> It will allow only single decimal dot (.)

=> It will only allow three digit decimal values after dot. you can modified by changing to {1,3} into below RegEx.

```
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
if (!string.length)
return YES;
NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string];
NSString *expression = @"^([0-9]+)?(\\.([0-9]{1,3})?)?$";
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:expression
options:NSRegularExpressionCaseInsensitive
error:nil];
NSUInteger numberOfMatches = [regex numberOfMatchesInString:newString
options:0
range:NSMakeRange(0, [newString length])];
if (numberOfMatches == 0)
return NO;
return YES;
}
```

Similar Questions

How to restrict the number of digits after the decimal point using onkeyup even in javascript? I want to restrict the number of digits after the decimal point based on an input already given in the

Hi I'm working on an assignment and got stuck on this part, how do I validate decimal numbers/numbers in shell? It can accept numbers but not decimal numbers. I want it to be able to accept both. This

Is it worth it to implement it in hardware? If yes why? If not why not? Sorry I thought it is clear that I am talking about Decimal Rational Numbers! Ok something like decNumber++ for C++, decimal f

I am trying to truncate decimal numbers to decimal places. Something like this: 5.467 -> 5.46 985.943 -> 985.94 toFixed(2) does just about the right thing but it rounds off the value. I don't n

If I use decimal pad for input of numbers the decimal changes depending of country and region format. May be as a point . or as a comma , And I do not have control over at which device the app is

I've limited the input field to only numbers through js but am not sure how to also allow decimals... function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode &g

Here is the code in C# to allow only one decimal point in a textbox: if textbox5.text.contains(.) && e.keychar=. { e.handled=true } I have to use it in VB.NET 2003 version, but I can't us

I need to set a jTextField to accept only numbers and one decimal point.Nothing else. Decimal point can't be typed more than once and no other characters are allowed. How can I do this? I typed this c

I'm making a website based on jQuery Mobile. On a particular field I would like to accept only numbers, or more precisely 4 digits. I noticed that the slider input does this (when you tap the field on

I'm trying to get my login form to only validate if only numbers were inputted. I can it to work if the input is only digits, but when i type any characters after a number, it will still validate etc.

Why do some numbers lose accuracy when stored as floating point numbers? For example, the decimal number 9.2 can be expressed exactly as a ratio of two decimal integers (92/10), both of which can be e

I'm using the commonly used Javascript function to allow only numbers to be inputted into a text field: function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode; if (charCode

I'd like to have a phone-like soft-keyboard that allows to input ONLY numbers. I can achieve the only numbers thing with inputType=number (where the soft-keyboard is as default but allows only nu

I'm using this function to only allow numbers in a text input. $('input').bind('keydown', function(e) { var key = e.charCode || e.keyCode || 0; return ( key == 8 || key == 9 || key == 46 || (key >=

Doing an billing application in php, There come price with decimals like 0.576 tried round() number_format() it will give me 0.58 but i want 0.57 only, how can i get in php?

I am using a Angular directive that formats input fields numbers with commas. I would also like this filter to automatically insert the decimal for cents.Every number will always have cents involved.

So I've been trying to do a regex in Sublime text on a CSV file to find any number that doesn't have any digits before the decimal point. Basically, I need to find any combinations of .xx or ,.xx in

In my HTML markup I have an input of type text which has a two-way binding (using ng-model) to a decimal property. The object which contains this decimal property is fetched using a Breeze query on th

I have a simple input tag to upload a file: <input type=file name=upfile class=myFile-Input multiple /> This works fine in IE, chrome, FX, but if I exceed 254 IE9 doesn't display the fil

I'm trying to limit my user input to conform to 999.99 I am using this code to try and exclude the entry of a second decimal point but it doesn't work. Can anyone help me out on this ? jQuery(.textr2

I would appreciate an answer how to solve the following problem. I use CarlosAg.ExcelXmlWriter and I have a problem with formatting decimal numbers in Excel. Example: I have SQL field TestField, Decim

Possible Duplicate: Parsing numbers safely and locale-sensitively How can I validate strings containing decimal numbers in a locale-sensitive way? NumberFormat.parse allows too much, and Double.pars

Can I use decimal numbers (18.9 or 75.5) for padding, margin or other styles? all browsers (such as IE5, IE6) support it? Thanks.

I'm new to Java and trying to take a BigDecimal (for example 99999999.99) and convert it to a string but without the decimal place and trailing numbers. Also, I don't want commas in the number and rou

Possible Duplicate: JavaScript: formatting number with exactly two decimals I need a JS (jQuery) script, that helps me limit the input of numbers to two decimal points. I have tried this and it work

i am looking to filter my input so it can contain only numbers re = /[^0-9]/; if(!re.test(form.number.value)) { alert(Member must contain only numbers. Please try again); form.member.focus(); retur

As round will round either up or down, it can't be used in my case all though you can control the decimal point. The problem is floor and ceil does not allow to control the decimal point, in case of f

I have data set as a varchar(500), but I only know if it's numeric or character. I need to count the max spaces of the length of a column AND the max spaces after a decimal point. For Example: ColumnA

I'm trying to learn Regex. Currently I'm trying to write a function that parses a float and sets a maximum number of decimal places (basically only allows two decimal points, but doesn't add them if

I am using validation in GWT. I am having textbox. In that field it accepts only whole numbers and decimal values not other than special characters . I used regex pattern [0-9*] but it does not acce

Whenever the user tries to enter a number not in the range [0, 24] it should show an error message. My code to accept floating point numbers is as follows. How can I modify it to add range validation?

Get maximum 13 numbers in an input type text box but if user presses 14 number as decimal, only then it should allow maximum 16 numbers. HTML: <input type=text maxlength=15 onkeyup=checkCurren

This question already has an answer here: Confusion with floating point numbers 2 answers When I store a float value of 12 decimal places after upto 6 decimals places it is showing fixed value.

I have a requirement to make a decimal textbox (Money textbox) which: only allows numbers 0-9 (allow upper numpad keys 0-9 and right numpad keys 0-9); allows only one dot which don't appear on start.

I have fully working calculator using java.Can tell me how to add decimal point.I already have the button and the variables are in type double.I just can't make the button work. I tried to do it mysel

For a website with financial calculations I try to convert every number included into an HTML input field to the format xxx,xxx,xxx.xx with comma for the thousand separator and point for decimal. Simi

I've developed a calculator and now would like to add a decimal point into operation. The code I'm using so far allows the decimal point button to be used and displayed, however when I click another n

I'd like to know if exists some function to automatically format a number by it's decimal, so if I have: <?php // $sql_result[col_number] == 1,455.75 number_format ($sql_result[col_number], 2,

I found many links regarding this question but none answers the problem correctly(completely). How to restrict user to allow only one decimal point in textbox. 1.3 , 5.6 etc (user cannot enter two dec

I am to compress location data (latitude,longitude, date,time). All the numbers are in fixed format. 2 of them (latitude,longitude) are with decimal format. Other 2 are integers. Now these numbers are

I am stuck on a project in my intro to Java class. We have to create a code that will convert a number to a Fixed Point Number. I've got that part okay, but where I am stuck is in the mathematics port

I want a regular expression which accepts only numbers 0-9 without any special character or decimal. Also single 0 should not be allowed but 0 followed by other numbers are allowed.

I made a method to input numbers. But I want that input is numeric but a dot (.) Can still be entered. please my friend help me. Thanks private void jTextField1KeyTyped(java.awt.event.KeyEvent evt)

To initialize the controls in my dialogs and to gather user input, I'm using DDX. How can I change the program to display float numbers with a comma instead of a point (best without changing the local

is there a way of formatting a string to show whole numbers of a decimal number if it follows 00. example show 10 if number is 10.00. but show 10.2 if number is 10.2 this is for c#, asp.net

I'm trying to make a regex that only allows the user to input numbers with a value of 2 or more (0 and 1 are not allowed)... I have been trying to pull this off for quite a while with no success yet..

I have an UINT16 unsigned integer of say 4455, 312, 560 or 70. How to use printf to insert a decimal point before the last two digits so the example numbers appear as 44.55, 3.12, 5.60 or 0.70 If th

I'd like to have the phone number field on this website only accept numbers or digits. I do not have access to edit the HTML code, so can this be done with jQuery by targeting the field's ID? If so, h

I have this string 45043. How can I convert it to decimal 450.43 (i want to use cultureinfo) tks

What I need to do is use integer arithmetic to convert fractions into floating point numbers. The number of decimal places needed is specified as a variable DECIMALS. Each fraction is contained in a t