我想设置一些数字到<input type="number">
像22,33,44,但在submited我的表单后,值到我的输入标记是“”,如果我只设置了两个数字,它就像“22.33”一样工作,但有3个数字,验证不通过。我如何设置3个或更多数字并通过验证?不能设置几个数字到<input type =“number”>
回答
改为使用<input type="text" pattern="(\d+)(,\s*\d+)*" />
。
可以工作,但请记住'^'和'$'隐含在模式 –
噢,是的。我会改变这一点。 – shilch
问题是逗号','你有。输入类型'数字'只占用数字,用逗号无效,删除逗号并且应该起作用
如果我删除逗号,它将只有一个数字,不是吗? –
是的,你应该采取输入类型'文本'和解析数字的方法。但我只是为了更好的可用性而使用多个输入 –
进入<input type="number">
你只能输入一个数字,“22.33”仍然是一个数字,但它是小数,而不是一个数字,这是正确的。
如果要插入用逗号(,)分隔的多个数字,则必须使用<input type="text">
,然后解析输入内容。
是的,这将是个好主意,但我不能使用“文本”类型,它的条件为这个输入。 –
您需要使用类型文本并使用正则表达式或字符串操作来执行验证。 输入类型=数字用于设置唯一的值,如22或33或44,但不能组合,即“22,33,44”。
所以这是使用“文本”类型的唯一方法?不幸的是我不能使用这种类型,它的条件为这个输入。 –
不,这是不可能的,你需要改变类型为文本和使用模式(猜测不支持IE9)执行验证,否则JS函数验证像做字符串。操作 – Bkjain655
- 1. 为什么<input type =“number”maxlength =“3”>在Safari中不工作?
- 2. <input type ='button'/>和<input type ='submit'/>之间的区别
- 3. 如何在<input type =“text”>标签内放置<input type =“file”>?
- 4. 样式<input type = number />微调箭头正确
- 5. <input type =“number”/>什么事件发生变化时触发?
- 6. HTML中的可编辑单位<input type =“number”>
- 7. Grails <field type =“number”...>不工作......?
- 8. <button>与<INPUT TYPE =“图像”>
- 9. HTML5 <input type =“date”> change
- 10. 为<input type ='submit'>
- 11. <type =“input”runat =“server”>
- 12. 增加<input type =“text”>
- 13. <input type =“text”/>换行
- 14. 验证<input type =“date”>
- 15. HTML5 - Android平板 - INPUT TYPE NUMBER
- 16. 不使用<input type =“file”/>
- 17. HTML <input type =“text”... as <input type =“file”
- 18. 另一个ASP:Textbox vs <input type =“text”>
- 19. 为什么HTML5中没有<input type =“picture”>和/或<input type =“video”>?
- 20. 制作一个<i>标记一个<input type ='button'>
- 21. 有没有办法为<input type =“number”>禁止科学记数法?
- 22. <input type = number>并在Chrome中使用一位小数的格式
- 23. 如何在IE10中设置<input type ='range'/>
- 24. 是否可以使用CSS来设置<input type =“file”>?
- 25. for input type =“number”如何将默认值设置为0
- 26. Facebook的 - 不能使用<INPUT TYPE =“文件”>标签
- 27. <input type =“number”>在Firefox中。为什么Mozilla不在浏览器中支持数字输入?
- 28. 如何将<input type =“image”>绑定到<input type =“text”>?两者都是相同的形式
- 29. 初学者:<input type =“folder”>?
- 30. 拆分<input type =“text”>使用Angular.js
'type =“number”'表示您只能输入**一个**实际编号 –
如何设置输入的少数数字?它仍然需要数字输入。 –