日期:2014-05-17  浏览次数:20538 次

javascript表单认证如如何结合NET进行写入数据库?
按钮点击就执行JS 认证,认证不通过就不提交,通过就提交,但是下面的代码写好一JS论证,但是如果结合NET?提交就执行NET写入数据库的操作?或者有其他的方法?

<div class="content">
<div class="cont1" style=" width:500px;margin-top:25px; background:#ffffff; padding:10px 50px">
<table align="center" width="978" style="margin:0px auto">
  <form name="theForm" id="demo" action="" method="get" onSubmit="return Validator.Validate(this,3)">
  <tr>
  <td>姓名:</td><td><input name="Name" dataType="Chinese" msg="只允许中文"></td>
  </tr>
  <tr>
  <td>地址</td><td><input name="Name" dataType="Chinese" msg="只允许中文"></td>
  </tr>
  <tr>
  <td>信箱:</td><td><input name="Email" dataType="Email" msg="信箱格式不正确"></td>
  </tr>
  <tr>
  <td>QQ:</td><td><input name="QQ" require="false" dataType="QQ" msg="QQ号码不存在"></td>
  </tr>
   
  <tr>
  <td>电话:</td><td><input name="Phone" require="false" dataType="Phone" msg="电话号码不正确"></td>
  </tr>
  <tr>
  <td>手机:</td><td><input name="Mobile" require="false" dataType="Mobile" msg="手机号码不正确"></td>
  </tr>
  <tr>
  <td></td><td colspan="2"><input name="Submit" style="width:80px; height:30px;" type="submit" value="确定提交"><input style="width:80px; height:30px;" type="reset"></td>
  </tr>
  </form>
 </table>
 <script>
 Validator = {
Require : /.+/,
Email : /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
Phone : /^((\(\d{3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}$/,
Mobile : /^((\(\d{3}\))|(\d{3}\-))?13\d{9}$/,
Url : /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/,
IdCard : /^\d{15}(\d{2}[A-Za-z0-9])?$/,
Currency : /^\d+(\.\d+)?$/,
Number : /^\d+$/,
Zip : /^[1-9]\d{5}$/,
QQ : /^[1-9]\d{4,8}$/,
Integer : /^[-\+]?\d+$/,
Double : /^[-\+]?\d+(\.\d+)?$/,
English : /^[A-Za-z]+$/,
Chinese : /^[\u0391-\uFFE5]+$/,
UnSafe : /^(([A-Z]*|[a-z]*|\d*|[-_\~!@#\$%\^&\*\.\(\)\[\]\{\}<>\?\\\/\'\"]*)|.{0,5})$|\s/,
IsSafe : function(str){return !this.UnSafe.test(str);},
SafeString : "this.IsSafe(value)",
Limit : "this.limit(value.length,getAttribute('min'), getAttribute('max'))",
LimitB : "this.limit(this.LenB(value), getAttribute('min'), getAttribute('max'))",
Date : "this.IsDate(value, getAttribute('min'), getAttribute('format'))",
Repeat : "value == document.getElementsByName(getAttribute('to'))[0].value",
Range : "getAttribute('min') < value && value < getAttribute('max')",
Compare : "this.compare(value,getAttribute('operator'),getAttribute('to'))",
Custom : "this.Exec(value, getAttribute('regexp'))",
Group : "this.MustChecked(getAttribute('name'), getAttribute('min'), getAttribute('max'))",
ErrorItem : [document.forms[0]],
ErrorMessage : ["以下原因导致提交失败:\t\t\t\t"],
Validate : function(theF