Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Android浏览器输入类型编号_Javascript_Android_Html_Android Browser - Fatal编程技术网

Javascript Android浏览器输入类型编号

Javascript Android浏览器输入类型编号,javascript,android,html,android-browser,Javascript,Android,Html,Android Browser,在Android浏览器(4.03)中发布以下标记 <html> <body> Androind 4.03 Browser test page<br /> Type .9 in the input field below and click/tap button below.<br /> Browser validation is clearing contents in input field.<br /></br/>

在Android浏览器(4.03)中发布以下标记

<html> 
<body> 
Androind 4.03 Browser test page<br />
Type .9 in the input field below and click/tap button below.<br />
Browser validation is clearing contents in input field.<br /></br/>


<input type="number" pattern="[0-9\.]*" step="0.1" min="0.0"></input> <br /><br /><br />

<input type="button" value="Validate" />

</body>
</html>

Android 4.03浏览器测试页
在下面的输入字段中键入.9,然后单击/点击下面的按钮。
浏览器验证正在清除输入字段中的内容。




我希望数字键盘在焦点上,它可以很好地与iphone和Android2.x浏览器配合使用。 但当我输入小于1的小数点时,比如.9或.1,它会验证onblur和clear输入字段

我希望输入可以接受任何数字和小数


这是一篇老文章,但我也遇到了这个问题

为了解决这个问题,我做的是在keydown上捕获“.”(keyup在android上运行良好,但在IOS上出现问题),并在输入之前将值设置为0。应用。 然而,我注意到,至少在android浏览器上,这干扰了在那之后完全擦除数字的能力(如果你要退格的话),所以我也必须抓住这一点

// within a keydown handler for the input, 
// where "this" is the input, and "e" is the event

// make it 0 before the . gets applied
if((e.keyCode == 190 || e.keyCode = 46)
    && (!this.value || this.value == '.'))
{
    this.value = 0;
    return;
}

// ...but that screws up the cursor position on
// some browsers, so handle the backspace 
if(e.keyCode == 8 && this.value == '0.')
{
    this.value = '';
    return;
}

感觉不舒服,但似乎有用。

以前的帖子,但我也遇到过这个问题

为了解决这个问题,我做的是在keydown上捕获“.”(keyup在android上运行良好,但在IOS上出现问题),并在输入之前将值设置为0。应用。 然而,我注意到,至少在android浏览器上,这干扰了在那之后完全擦除数字的能力(如果你要退格的话),所以我也必须抓住这一点

// within a keydown handler for the input, 
// where "this" is the input, and "e" is the event

// make it 0 before the . gets applied
if((e.keyCode == 190 || e.keyCode = 46)
    && (!this.value || this.value == '.'))
{
    this.value = 0;
    return;
}

// ...but that screws up the cursor position on
// some browsers, so handle the backspace 
if(e.keyCode == 8 && this.value == '0.')
{
    this.value = '';
    return;
}
感觉不舒服,但似乎有效