<script language="javascript" type="text/javascript"> function validate() ...{ if (document.getElementById("txtName").value=="") ...{ alert(" Name Not Found "); document.getElementById("txtname").focus(); returnfalse; } if (document.getElementById("txtemail").value=="") ...{ alert("Email Cant Not Find"); document.getElementById("txtEmail").focus(); returnfalse; } var emailPat="^[a-zA-Z0-9_.]+@[a-zA-Z0-9-]+[.a-zA-Z]+$"; var emailID=document.getElementById("txtEmail").value; var matchArray=emailID.match(emailPat); if (matchArray==null) ...{ alert('Your email address seems incorrect. Please try again.'); document.getElementById("txtEmail").focus(); returnfalse; } var digits="0123456789"; var temp; for(i=0;document.getElementById("txtZip").value.length;i++) ...{ temp=document.getElementById("txtZip").value.substring(i,i+1); if (digits.indexOf(temp)==-1) ...{ alert("please enter current zip code"); document.getElementById("txtZip").focus(); returnfalse; } } returntrue; } </script>
第一步:在asp.net页面写javascript方法放在之间 script language="javascript" type="text/javascript"> function validate() ...{ if (document.getElementById("txtName").value=="") ...{