Foxtable(狐表)用户栏目专家坐堂 → [求助]身份证后面带X无法输入?


  共有1925人关注过本帖树形打印复制链接

主题:[求助]身份证后面带X无法输入?

帅哥哟,离线,有人找我吗?
6378929
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:257 积分:2054 威望:0 精华:0 注册:2016/1/4 8:54:00
[求助]身份证后面带X无法输入?  发帖心情 Post By:2017/7/30 8:19:00 [只看该作者]

身份证后面带X无法输入?请求代码

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/30 9:21:00 [只看该作者]

你写了什么的验证代码,贴出来看看。


 回到顶部
帅哥哟,离线,有人找我吗?
6378929
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:257 积分:2054 威望:0 精华:0 注册:2016/1/4 8:54:00
  发帖心情 Post By:2017/7/30 10:04:00 [只看该作者]

If len(e.Form.Controls("TextBox1").text) < 17
    If Char.IsNumber(e.KeyChar) OrElse Char.IsControl(e.KeyChar)
    Else
        MessageBox.show("对不起,您输入的字符不合法,请仔细检查!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
        e.Cancel  = True
    End If
Else If  len(e.Form.Controls("TextBox1").text) = 17
    If Char.IsNumber(e.KeyChar) OrElse e.KeyChar = "X" OrElse Char.IsControl(e.KeyChar) Then
        If e.KeyChar = "x"
            e.Sender.SelectedText = e.KeyChar.ToUpper
            e.Cancel = True
        End If
    Else
        MessageBox.show("对不起,您输入的字符不合法,请仔细检查!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
        e.Cancel  = True
    End If
Else If len(e.Form.Controls("TextBox1").text) > 17
    If Char.IsControl(e.KeyChar)
    Else
        MessageBox.show("对不起,身份证号码已达到最大长度18位,请仔细检查!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
        e.Cancel  = True
    End If
End If

 回到顶部
帅哥哟,离线,有人找我吗?
6378929
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:257 积分:2054 威望:0 精华:0 注册:2016/1/4 8:54:00
  发帖心情 Post By:2017/7/30 10:06:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20170730100725.png
图片点击可在新窗口打开查看

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/30 10:45:00 [只看该作者]

 4楼的提示,和你3楼的代码无关。请贴出正确的出错代码。

 回到顶部
帅哥哟,离线,有人找我吗?
程兴刚
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:超级版主 帖子:7237 积分:40614 威望:0 精华:16 注册:2008/8/31 23:23:00
  发帖心情 Post By:2017/7/31 5:56:00 [只看该作者]

我发布过一个带验证的,自己搜一下!

 回到顶部
帅哥哟,离线,有人找我吗?
6378929
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:257 积分:2054 威望:0 精华:0 注册:2016/1/4 8:54:00
  发帖心情 Post By:2017/7/31 8:27:00 [只看该作者]


If e.DataCol.name = "身份证号码"
    If e.DataRow.isnull("身份证号码") = False
        Dim sum,ai,n As Integer
        If len(e.DataRow("身份证号码")) > 15
            If len(e.DataRow("身份证号码")) = 18
                If IsNumeric(e.DataRow("身份证号码")) = True OrElse IsNumeric(left(e.DataRow("身份证号码"),17)) = True And right(e.DataRow("身份证号码"),1) = "X"
                    Dim wi() As Integer = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}
                    For i As Integer = 0 To 16
                        ai = e.DataRow("身份证号码").SubString(i,1)
                        sum = sum + ai*wi(i)
                    Next
                    n = sum Mod 11
                    Dim jym() As String = {"1","0","X","9","8","7","6","5","4","3","2"}
                    If jym(n) = right(e.DataRow("身份证号码"),1)
                        Dim y,m,d As Integer
                        y = e.DataRow("身份证号码").SubString(6,4)
                        m = e.DataRow("身份证号码").SubString(10,2)
                        d = e.DataRow("身份证号码").SubString(12,2)
                        If y > 1900 And y < 2100 And m > 0 And m < 13
                            If d > 0 And d <= Date.DaysInMonth(y,m)
                                e.DataRow("出生日期") = new Date(y,m,d)
                            Else
                                MessageBox.show("对不起,检测到该身份证号码持有人的出生日期的日数据不合法,请检查!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                                Return
                            End If
                        Else
                            MessageBox.show("对不起,检测到该身份证号码持有人的出生日期的月数据不合法,请检查!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                            Return
                        End If
                        n = e.DataRow("身份证号码").SubString(16,1) Mod 2
                        If n = 1
                            e.DataRow("性别") = "男"
                        Else
                            e.DataRow("性别") = "女"
                        End If
                        Dim s As String = e.DataRow("身份证号码").SubString(0,2) & "0000"
                        Dim dq As String
                        Dim dr As DataRow
                        dr = DataTables("身份证地区编码").find("编码 = " & s)
                        If dr IsNot Nothing
                            dq = dr("县级以上地区名称")
                        End If
                        s = e.DataRow("身份证号码").SubString(0,4) & "00"
                        dr = DataTables("身份证地区编码").find("编码 = " & s)
                        If dr IsNot Nothing
                            dq = dq & dr("县级以上地区名称")
                        Else
                            s = e.DataRow("身份证号码").SubString(0,3) & "000"
                            dr = DataTables("身份证地区编码").find("编码 = " & s)
                            If dr IsNot Nothing
                                dq = dq & dr("县级以上地区名称")
                            End If
                        End If
                        s = e.DataRow("身份证号码").SubString(0,5) & "0"
                        dr = DataTables("身份证地区编码").find("编码 = " & s)
                        If dr IsNot Nothing
                            dq = dq & dr("县级以上地区名称")
                        End If
                        s = e.DataRow("身份证号码").SubString(0,6)
                        dr = DataTables("身份证地区编码").find("编码 = " & s)
                        If dr IsNot Nothing
                            dq = dq & dr("县级以上地区名称")
                        End If
                        e.DataRow("籍贯") = dq
                    Else
                        MessageBox.show("对不起,该身份证号码无法通过验证,请检查!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                    End If
                Else
                    MessageBox.show("对不起,身份证号码字符格式不合法,请重新输入!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                End If
            Else
                MessageBox.show("对不起,身份证号码长度不合法,请重新输入!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
            End If
        Else
            If len(e.DataRow("身份证号码")) < 15
                MessageBox.show("对不起,身份证号码长度不合法,请重新输入!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
            Else
                Dim y,m,d As Integer
                y = e.DataRow("身份证号码").SubString(6,2)
                y = 1900 + y
                m = e.DataRow("身份证号码").SubString(8,2)
                d = e.DataRow("身份证号码").SubString(10,2)
                If m > 0 And m < 13
                    If d > 0 And d <= Date.DaysInMonth(y,m)
                        e.DataRow("出生日期") = new Date(y,m,d)
                    Else
                        MessageBox.show("对不起,检测到该身份证号码持有人的出生日期的日数据不合法,请检查!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                        Return
                    End If
                Else
                    MessageBox.show("对不起,检测到该身份证号码持有人的出生日期的月数据不合法,请检查!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Return
                End If
                n = e.DataRow("身份证号码").SubString(14,1) Mod 2
                If n = 1
                    e.DataRow("性别") = "男"
                Else
                    e.DataRow("性别") = "女"
                End If
                Dim s As String = e.DataRow("身份证号码").SubString(0,2) & "0000"
                Dim dq As String
                Dim dr As DataRow
                dr = DataTables("身份证地区编码").find("编码 = " & s)
                If dr IsNot Nothing
                    dq = dr("县级以上地区名称")
                End If
                s = e.DataRow("身份证号码").SubString(0,4) & "00"
                dr = DataTables("身份证地区编码").find("编码 = " & s)
                If dr IsNot Nothing
                    dq = dq & dr("县级以上地区名称")
                Else
                    s = e.DataRow("身份证号码").SubString(0,3) & "000"
                    dr = DataTables("身份证地区编码").find("编码 = " & s)
                    If dr IsNot Nothing
                        dq = dq & dr("县级以上地区名称")
                    End If
                End If
                s = e.DataRow("身份证号码").SubString(0,5) & "0"
                dr = DataTables("身份证地区编码").find("编码 = " & s)
                If dr IsNot Nothing
                    dq = dq & dr("县级以上地区名称")
                End If
                s = e.DataRow("身份证号码").SubString(0,6)
                dr = DataTables("身份证地区编码").find("编码 = " & s)
                If dr IsNot Nothing
                    dq = dq & dr("县级以上地区名称")
                End If
                e.DataRow("籍贯") = dq
                
            End If
        End If
    Else
        e.DataRow("性别") = Nothing
        e.DataRow("出生日期") = Nothing
        e.DataRow("籍贯") = Nothing
    End If
End If
If e.DataCol.name = "出生日期"
    If e.DataRow.isnull("出生日期") = False
        Dim tp As TimeSpan = Date.today - CDate(e.DataRow("出生日期"))
        e.DataRow("年龄") = Math.Round(tp.TotalDays / 365.2422,2)
    Else
        e.DataRow("年龄") = Nothing
    End If
End If

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/31 8:39:00 [只看该作者]

代码没有问题,请做具体实例上来测试。

 回到顶部