范围可能是例如5到10,这是我到目前为止所做的,但仍然没有达到我想要的
<script>
function checkpattern(elem)
{
var textbox = document.getElementById("textbox");
if(textbox.value.length<=10 && textbox.value.length>=5)
{
alert("5 to 10");
}
else
{
if(!elem.value.match('^'+elem.getAttribute('pattern')+'$'))
{
alert('Accepts digits only');
}
}
}
</script>
<input type = "text" name = "amt" maxlength = "10" pattern = [0-9] onchange = checkpattern(this) placeholder="Enter Amount" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter Amount '" required="">
繁星淼淼
拉丁的传说
相关分类