<input type="text" style="width: 50%; height: 18px;"
onkeyup="this.value=this.value.replace(/\D/g,'')"
onafterpaste="this.value=this.value.replace(/\D/g,'')"
maxlength="11" name="tph" id="tph" />
onkeyup="this.value=this.value.replace(/\D/g,'')"
onafterpaste="this.value=this.value.replace(/\D/g,'')"
maxlength="11" name="tph" id="tph" />
本文介绍了一种通过JavaScript实现的文本输入框格式控制方法,该方法能够确保用户输入的数据仅包含数字,并限制了输入的最大长度为11位。这种方法适用于电话号码等需要特定格式的数据收集场景。
1527

被折叠的 条评论
为什么被折叠?



