文本框的多个最小值和最大值

Hsu*_*ueh 5 javascript jquery html5 angularjs

我有一个工作代码,使用以下代码在文本框中输入有效的最小值和最大值:

<input type="number" name="quantity" min="1" max="5">
Run Code Online (Sandbox Code Playgroud)

但是,如果允许多个范围怎么样?例如:在我的文本框中,允许使用1到5和10到15之间的数字,因此不允许使用6-9和16及以上的数字.如何使用javascript/jquery或angularjs做到这一点?

Hsu*_*ueh 1

感谢所有的答案。我尝试了一切,但我通过使用 if/else 语句得到了它。

if (txt>=1 && txt<=5){
  return true
}
if (txt>=10 && txt<=15){
  return true
}
if (txt>=20 && txt<=25){
  return true
}else{
  alert("invalid")
  return false
}
Run Code Online (Sandbox Code Playgroud)