分享一下
<script>
function txtChange(val){
var flag=0;
switch(true){
case Boolean(val.match(/\;|\,/)):
case Boolean(val.match(/(^\,)|(\,$)/)):
case Boolean(val.match(/\,[\s]*\,/)):
flag=1;
}
if(flag)
alert("error message");
}
</script>
<input type="text" onchange="txtChange(this.value);" />