Foxtable(狐表)用户栏目专家坐堂 → 以A开头的14位编码的验证


  共有2064人关注过本帖平板打印复制链接

主题:以A开头的14位编码的验证

美女呀,离线,留言给我吧!
susu312
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:997 积分:6752 威望:0 精华:0 注册:2018/6/8 16:17:00
以A开头的14位编码的验证  发帖心情 Post By:2018/9/3 10:32:00 [只看该作者]

需求:机构编码是以A开头的14位数

 

validating:

 

Dim pattern As String =  "^A[0-9]{13}$"
Dim txt As String = e.Sender.Text
If txt > "" Then
    Dim rgx = new System.Text.RegularExpressions.Regex(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase)
    If rgx.isMatch(txt) = False Then
        e.Sender.Error = "机构编码是以A开头的14位数!"
        e.cancel = True
    Else
        e.Sender.Error = ""
    End If
Else
    e.Sender.Error = ""
End If

 

keydown:

If e.KeyCode =Asc("A") OrElse e.KeyCode >= Asc("0") AndAlso e.keycode <= Asc("9") Then
    If e.sender.text.length > 13 Then
        e.cancel = True
    End If

ElseIf e.KeyCode <> Keys.back Then
    e.cancel = True

End If

 

老师,这个小写a也能输进去,还有就是应该只允许输入A和数字,,请老师帮忙改一下


 回到顶部