使用<input type =“text”for =“”calculator =“”input =“”而不是=“”=“”<input =“”type =“number”

时间:2016-10-07 11:19:18

标签: html input

1 个答案:

答案 0 :(得分:0)

关于活动onclick&#39;或者&#39; onsubmit&#39;或者&#39; onblur&#39;发生在提交按钮上,你调用一个javascript函数将它们转换为数值。

我建议你去了解javascript。

 1) how read the value of the DOM element of your input field.
 2)How to remove/(or replace with null) the characters except numbers from variable.(learn about regular expression in string replace/remove)
 3) how to writes the value of variable to teh DOM element (Your's input field)

在提交表格之前这样做。

您可以参考How to make HTML input tag only accept numerical values?

中已提出的问题