$(function(){ $('#btn').click(function(){ var val =$('#not_digit').val(); var patrn = /^[0-9]*$/; if (!patrn.test(val)) { alert('包含不是数字的字符'); } });