<input type="text" maxlength="5" /> //可以 <input type="number" maxlength="5" /> //没有效果 <input type="number" oninput="if(value.length>5) value=value.slice(0,5)" /> //js控制,可以 <input type="tel" maxlength="5" /> //tel类型,可以
此外,tel类型的input在ios上会调出全数字键盘,而number类型的input则会调出带有标点符号的键盘。
原文:http://www.cnblogs.com/mengff/p/7349904.html