【发布时间】:2021-12-08 13:12:22
【问题描述】:
我是编程新手,我认为我的问题很简单,但我没有任何想法。如何检查文本字段中的字符数是否匹配 11?我试过了,但我认为这不是一个好的线索。
<form name="formz">
<input type='text' name='numbere' id="p" maxlength="11">
</form>
<button onclick="writee()">x</button>
<script>
function writee(){
win=window.open(" ","tab","width=300,height=350")
win.document.open()
var l = document.forms["formz"].numbere;
if(l.length==11){
win.document.write( "under 11 characters <br/>");
}else{
win.document.write( " 11 characters <br/>");
}
}
【问题讨论】:
-
<input minlength="11" maxlength="11" />完成。
标签: javascript validation