62,243
社区成员




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<input type="text" name="val" id="val" />
<input id="btnck" type="button" value="检测" />
</body>
<script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$("#btnck").click(function () {
var rgx = /^[\d\w!@#\^&_\-+]*$/g;
if (!rgx.test($("#val").val())) {
alert("输入错误");
}
})
</script>
</html>
static void Main(string[] args)
{
string input = "1234,a_d3";
string pattern = @"[^\w\!\@\#\^\&\-\+\/+]";
Regex regex = new Regex(pattern);
Match m = regex.Match(input);
if (m.Success)
{
Console.WriteLine("输入错误");
}
else
{
Console.WriteLine("输入正确");
}
Console.Read();
}