var reg = /\d+\,/g
var strNum = str.match(reg)
console.log(strNum)
采纳即可
<input type="checkbox" name="C1" id="a1" value="11" checked onclick="ab()" >11<input type="checkbox" name="C1" id="a2" value="22" checked onclick="ab()" >22
<input type="checkbox" name="C1" id="a3" value="33" onclick="ab()" >33
<input type="checkbox" name="C1" id="a4" value="44" onclick="ab()">44
<input type="text" id="b" value="11,22" size="20" >
<input type="text" id="d" value="" size="20" >
<input type="button" value="按钮" name="B3" onclick="abc()">
<script type="text/javascript">
var b = document.getElementById("b").value
var d = document.getElementById("d").value
var checkboxes = document.getElementsByName("c1")
for (var idx = 0idx <checkboxes.lengthidx++) {
if (checkboxes[idx].checked == true)
checkboxes[idx].setAttribute("saved", "true")
}
function ab() {
var c = document.getElementsByName("c1")
var b = document.getElementById("b")
var d = document.getElementById("d")
d.value = ""
b.value = ""
for (var i = 0i <c.lengthi++) {
if (c[i].checked == true) {
c[i].setAttribute("saved", "true")
b.value += c[i].value + ","
}
}
for (var k = 0k <c.lengthk++) {
if (c[k].checked == false &&c[k].getAttribute("saved")=="true" ) {
d.value += c[k].value + ","
}
}
}
function abc() {
if (b == document.getElementById("b").value) {
alert("1")
}
else {
alert("2")
}
}
</script>