<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="zzbds.aspx.cs" Inherits="GL.Newera.zzbds" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>正则表达式 demo</title>
<meta name="Keywords" content="" />
<meta name="Description" content="" />
</head>
<body>
<input type="text" id="input" />
<button id="go">验证</button>
<script type="text/javascript">
//文本框只能输入数字和小数点、且小数点后只能为2位数、小数点不能在第一位/^\d+(\.\d{2})?$/
var input1 = document.getElementById('input');
var btn1 = document.getElementById('go');
var reg2 = /^(\d+\.\d{1,4}|\d+)$/;
btn1.onclick = function(){
var val = input1.value;
if(!reg2.test(val))
{
alert( "只能输入数字和小数点、且小数点后只能为2位数、小数点不能在第一位");
}
}
</script>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="zzbds.aspx.cs" Inherits="GL.Newera.zzbds" %>
正则表达式 demo验证