js:
function checkOneToHundred(filed){ var a=filed.value; var reg = new RegExp("^(\\d|[1-9]\\d|100)$"); if(!reg.test(a)) { layer.alert("请输入0-100的整数!", { skin: 'layui-layer-lan' //样式类名 ,closeBtn: 0 ,move: false ,scrollbar: false }); } }
java:
import java.util.regex.Pattern; Pattern.matches("^(\\d|[1-9]\\d|100)$", "内容");