ValidateFunction~

 Public Shared Function ValidaterSummy(ByVal ctl As ArrayList, ByVal ErrLabel As HtmlImage, ByVal Title As String, ByVal VTyper As Long) As Boolean
        Select Case VTyper

            Case enumValidateType.VD_NOTNULL 'NOTNULL
                Select Case ctl(0).GetType.Name
                    Case "TextBox"
                        If String.IsNullOrEmpty(CType(ctl(0), TextBox).Text.Trim) Then
                            ErrLabel.Alt = Resources.error.errNoInput.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                    Case "DropDownList"
                        If String.IsNullOrEmpty(CType(ctl(0), DropDownList).SelectedItem.Value.Trim) Then
                            ErrLabel.Alt = Resources.error.errNoSelect.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                    Case "ListBox"
                        If CType(ctl(0), ListBox).Items.Count = 0 Then
                            ErrLabel.Alt = Resources.error.errNoSelect.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                End Select

            Case enumValidateType.VD_EMAIL 'Email書式
                Select Case ctl(0).GetType.Name
                    Case "TextBox"
                        If Not mailCheck(CType(ctl(0), TextBox).Text.Trim) Then
                            ErrLabel.Alt = Resources.error.errEmail.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                End Select
            Case enumValidateType.VD_DATE '日付書式
                Select Case ctl(0).GetType.Name
                    Case "HtmlInputText"
                        If CType(ctl(0), HtmlInputText).Value.Trim > CType(ctl(1), HtmlInputText).Value.Trim Then
                            ErrLabel.Alt = Resources.error.errFromTo.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                End Select
            Case enumValidateType.VD_AREA
                Select Case ctl(0).GetType.Name
                    Case "TextBox"
                        If CType(ctl(0), TextBox).Text.Trim > CType(ctl(1), TextBox).Text.Trim Then
                            ErrLabel.Alt = Resources.error.errFromTo.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                End Select
            Case enumValidateType.VD_NUMBICE
                Select Case ctl(0).GetType.Name
                    Case "TextBox"
                        If Not IsNumeric(CType(ctl(0), TextBox).Text.Trim) Then
                            ErrLabel.Alt = Resources.error.errFormatInput.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                End Select
            Case enumValidateType.VD_XIAOSHU
                Return False
            Case enumValidateType.VD_ZHENGSHU
                Return False
            Case enumValidateType.VD_NUMBER
                Select Case ctl(0).GetType.Name
                    Case "TextBox"
                        If Not IsInteger(CType(ctl(0), TextBox).Text.Trim) Then
                            ErrLabel.Alt = Resources.error.errInputPlus.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                End Select
            Case enumValidateType.VD_TEL '電話書式
                Return False
            Case enumValidateType.VD_LEN500
                Select Case ctl(0).GetType.Name
                    Case "TextBox"
                        If CType(ctl(0), TextBox).Text.Length > 500 Then
                            ErrLabel.Alt = Resources.error.errCount500.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                End Select
            Case enumValidateType.VD_LEN30
                Select Case ctl(0).GetType.Name
                    Case "TextBox"
                        If CType(ctl(0), TextBox).Text.Length > 30 Then
                            ErrLabel.Alt = Resources.error.errCount30.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                End Select
            Case enumValidateType.VD_LEN50
                Select Case ctl(0).GetType.Name
                    Case "TextBox"
                        If CType(ctl(0), TextBox).Text.Length > 50 Then
                            ErrLabel.Alt = Resources.error.errCount50.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                End Select
            Case enumValidateType.VD_LEN200
                Select Case ctl(0).GetType.Name
                    Case "TextBox"
                        If CType(ctl(0), TextBox).Text.Length > 200 Then
                            ErrLabel.Alt = Resources.error.errCount200.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                End Select
            Case enumValidateType.VD_FOLDER
                Select Case ctl(0).GetType.Name
                    Case "TextBox"
                        If String.IsNullOrEmpty(CType(ctl(0), TextBox).Text.Trim) Then
                            ErrLabel.Alt = Resources.error.errNoInput.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        ElseIf Tool.markFolder(CType(ctl(0), TextBox).Text.Trim) Then
                            ErrLabel.Alt = Resources.error.errFormatInput.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                End Select
            Case enumValidateType.VD_NUM20
                Select Case ctl(0).GetType.Name
                    Case "TextBox"
                        If Integer.Parse(CType(ctl(0), TextBox).Text.Trim) > 20 Then
                            ErrLabel.Alt = Resources.error.errNum20.Replace("$1", Title)
                            ErrLabel.Visible = True
                            Return False
                        End If
                End Select
        End Select
        ValidaterSummy = True
    End Function

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值