本文介绍了如何在文本框中设置最大长度为6和最小长度为6?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< input id =groupidtexttype =textstyle =width:100px; maxlength =6/>< / td>
有没有办法让最小长度为6? 请注意,这种方法适用于不支持旧版本的浏览器HTML 5,但依赖于开启了javascript的用户。
< input onblur =checkLength(this)id =groupidtexttype =textstyle =width:100px; maxlength =6/>
函数checkLength(el){
if(el.value.length!= 6){
alert(length must be 6 characters)
b
<input id="groupidtext" type="text" style="width: 100px;" maxlength="6" /></td>
Is there any way to get the minimum length to 6?
解决方案
you could do it with javascipt with something like this :
<input onblur="checkLength(this)" id="groupidtext" type="text" style="width: 100px;" maxlength="6" />
<!-- or use event onkeyup instead if you want to check every character strike-->
function checkLength(el) {
if (el.value.length != 6) {
alert("length must be exactly 6 characters")
}
}
Note this would work in older browsers which don't support HTML 5, but relies on the user having javascript switched on.
这篇关于如何在文本框中设置最大长度为6和最小长度为6?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!