身份证编号,验证代码

作者: 韦德国际1946国际网址  发布:2019-05-28

<% if request("check")<>"" then
astr=request("content")
call str(astr)
end if
function str(astr)
Ar=Cint(Asc(astr))
if(65<=Ar and Ar<=90) or (97<=Ar and Ar<=122) then
response.Write "<script>alert('输入的字符串是英文字母!!');</script>"
else
response.write "<script>alert('输入的字符串不是英文字母!!');</script>"
end if
end function

 代码如下

<%@ Page Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" EnableEventValidation="false" validateRequest="false" CodeBehind="Vote.aspx.cs" Inherits="dupcit.Vote" %>

<%@ Register Src="UserControl/WebUserControl1.ascx" TagName="WebUserControl1" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="container">      
<div id="side-a"> 
 <!-----涂聚文 2011-05-22----->

    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="True" EnableScriptLocalization="True">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>

        <table style="width: 587px; margin-left:auto; margin-right:auto;">
            <tr>
                <td style="width: 118px">
                </td>
                <td style="width: 505px">客户留言
                </td>
            </tr>
            <tr>
                <td style="width: 118px">
                    姓        名:</td>
                <td style="width: 505px">
                    <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName"
                        Display="Dynamic" ErrorMessage="姓名不能为空"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td style="width: 118px">
                    性        别:</td>
                <td style="width: 505px">
                    <asp:DropDownList ID="ddlSex" runat="server">
                        <asp:ListItem>男</asp:ListItem>
                        <asp:ListItem>女</asp:ListItem>
                    </asp:DropDownList></td>
            </tr>
            <tr>
                <td style="width: 118px">
                    出生日期:</td>
                <td style="width: 505px">
                    <asp:TextBox ID="txtBirthday" runat="server"></asp:TextBox> 
                    <ajax:CalendarExtender ID="CalendarExtender1" runat="server" Format="yyyy-MM-dd"
                        TargetControlID="txtBirthday">
                    </ajax:CalendarExtender>
                </td>
            </tr>
            <tr>
                <td style="width: 118px; height: 21px">
                    电子邮件:</td>
                <td style="height: 21px; width: 505px;">
                    <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>  
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
                        ErrorMessage="电子邮件格式不对" ValidationExpression="w ([- .']w )*@w ([-.]w )*.w ([-.]w )*">请输入电子邮件</asp:RegularExpressionValidator></td>
            </tr>
            <tr>
                <td style="width: 118px; height: 21px">
                    公司名称:</td>
                <td style="height: 21px; width: 505px;">
                    <asp:TextBox ID="txtCoName" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Display="Dynamic"
                        ErrorMessage="公司名称不能为空" ControlToValidate="txtCoName"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td style="width: 118px">
                    通讯地址:</td>
                <td style="width: 505px">
                    <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 118px">
                    邮政编码:</td>
                <td style="width: 505px">
                    <asp:TextBox ID="txtPost" runat="server"></asp:TextBox>
                    <ajax:MaskedEditExtender ID="MaskedEditExtender3" runat="server" Mask="999999" MaskType="number" TargetControlID="txtPost">
                    </ajax:MaskedEditExtender>
                    <ajax:MaskedEditValidator ID="MaskedEditValidator3" runat="server" ControlExtender="MaskedEditExtender3"
                        ControlToValidate="txtPost" IsValidEmpty="False"></ajax:MaskedEditValidator></td>
            </tr>
            <tr>
                <td style="width: 118px">
                    联系电话</td>
                <td style="width: 505px">
                    <asp:TextBox ID="txtTel" runat="server"></asp:TextBox> 
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ControlToValidate="txtTel"
                        ErrorMessage="请输入正确的电话号码" ValidationExpression="(0?d{3}-?d{7,8})"></asp:RegularExpressionValidator></td>
            </tr>
            <tr>
                <td style="width: 118px; height: 26px;">
                    手机号码:</td>
                <td style="height: 26px; width: 505px;">
                    <asp:TextBox ID="txtMobile" runat="server"></asp:TextBox> 
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" ControlToValidate="txtMobile"
                        ErrorMessage="输入正确的手机号" ValidationExpression="d{11}|(d{3,4}-)?d{7,8}"></asp:RegularExpressionValidator></td>
            </tr>
            <tr>
                <td style="width: 118px">
                    传真号码:</td>
                <td style="width: 505px">
                    <asp:TextBox ID="txtFax" runat="server"></asp:TextBox> 
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="txtFax"
                        ErrorMessage="请输入正确的传真号码" ValidationExpression="(0?d{3}-?d{7,8})"></asp:RegularExpressionValidator></td>
            </tr>
            <tr>
                <td style="width: 118px; height: 26px;">
                    身份证号码:</td>
                <td style="height: 26px; width: 505px;">
                    <asp:TextBox ID="textICD" runat="server"></asp:TextBox>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator6" runat="server" ControlToValidate="textICD"
                        ErrorMessage="请输入正确的身份证号码" ValidationExpression="d{17}[d|X]|d{15}"></asp:RegularExpressionValidator></td>
            </tr>
            <tr>
                <td style="width: 118px">
                    公司网址:</td>
                <td style="width: 505px">
                    <asp:TextBox ID="txtWebsite" runat="server"></asp:TextBox>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtWebsite"
                        ErrorMessage="请输入正确的网址" ValidationExpression="http(s)?://([w-] .) [w-] (/[w- ./?%&=]*)?">请输入网址</asp:RegularExpressionValidator></td>
            </tr>
            <tr>
                <td style="width: 118px">
                    留言主题:</td>
                <td style="width: 505px">
                    <asp:TextBox ID="txtTitle" runat="server"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 118px">
                    留言类型:</td>
                <td style="width: 505px">
                    <asp:DropDownList ID="ddlType" runat="server">
                    </asp:DropDownList></td>
            </tr>
            <tr>
                <td style="width: 118px; height: 120px; vertical-align:top;">
                    留言内容:</td>
                <td style="height: 120px; width: 505px;">

                    <FCKeditorV2:FCKeditor runat="server" Height="330px" ID="FCKeditor1" ToolbarSet="Basic" >

                    </FCKeditorV2:FCKeditor><asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="内容不能为空" ControlToValidate="FCKeditor1" Display="Dynamic"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td style="width: 118px; height: 21px;">
                </td>
                <td style="height: 21px; width: 505px;">
                    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="确定" /></td>
            </tr>
        </table>
            </ContentTemplate>
        </asp:UpdatePanel>    
    </div>


    </div>        
        <div id="side-b">
            <uc1:WebUserControl1 ID="WebUserControl1_1" runat="server" />



        </div>        
        </div>
</asp:Content>



        /// <summary>
        ///涂聚文 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
                //验证提示 
            if (Page.IsValid)
            {
                Response.Write("验证成功");
            }
            else
            {
                Response.Write("验证no成功");
            }

        }

亟待一个简练的印证身份证号的正则表达式,从英特网查了广大,都有标题,重若是倘使超越十八个人,都能够通过,于是自个儿查了半天手册,写了上边那么些姿势,能够满意简单的渴求:
一、一八人或拾7位,假如是二10个人,必需全都以数字。
2、假若是二11位,最后壹位能够是数字或字母Xx,别的必需是数字。

%>

function funczip($str)//邮政编码正则表明试
{
 return (preg_match("/^[0-9]d{5}$/",$str))?true:false;
}

/^(身份证编号,验证代码。d{15}$|^d{18}$|^d{17}(d|X|x))$/

劳动器端验证Email是还是不是正确

<%
Function F_RegExp(Expression, IfStr)
Dim RegExp1, Matches
Set ObjExp = New RegExp '创建正则表达式
ObjExp.Pattern = Expression '设置情势
ObjExp.IgnoreCase = True '设置是不是区分字符大小写
ObjExp.Global = True '设置全局可用性
Matches = ObjExp.Test(IfStr)
F_RegExp = Matches
End Function
function checkemail(str)
checkemail=F_RegExp("w ([- .']w )*@w ([-.]w )*.w ([-.]w )*",trim(str))
end function
%>
<%
if request.form("e_mail")<>"" then
if cbool(checkemail(request.form("e_mail"))) then
response.Write("您输入的Email地址准确!")
else
response.Write("您输入的Email地址错误!")
end if
else
response.Write("您未有输入Email地址!")
end if
%>

if( funczip('421800') )
{
 echo '邮政编码填写准确';
}
else
{
 echo '邮箱书写错误';
}

从这一个表达式想到的:
1、正则表明式首先是要通过正确的
贰、限制不科学
3、能够不限量个中的某此规则,但显明要让科学的先经过。

本文由韦德国际1946发布于韦德国际1946国际网址,转载请注明出处:身份证编号,验证代码

关键词: csharp code csharp