1

我正在寻找一个可以CustomValidator详细解释的好网站。如果有人有去请告诉我。以下代码检查结果中是否至少有 10 个数字。但是,我也希望它验证这些值是数字。使用CustomValidatorinvb.net有没有办法将其作为“and if”语句来执行?

谢谢

Sub AtLeastTenNumbers_ServerValidate(ByVal source As Object, _
ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)

    If area_code.Text.Length + phone_1.Text.Length + phone_2.Text.Length > 9 Then
        args.IsValid = True
    Else
        args.IsValid = False
    End If

End Sub
4

1 回答 1

3

This is a bit of an old article, but Scott Mitchell knows his stuff:

http://www.4guysfromrolla.com/articles/073102-1.aspx

is there a way to do this as an "and if" statement?

You can always nest an if statement inside of your current statement.

If area_code.Text.Length + phone_1.Text.Length + phone_2.Text.Length > 9 Then 
    args.IsValid = True 
    'Check to see if this part is numeric
    If IsNumeric(phone_1.Text) Then
       ' Do Logic here
    End If
Else 
    args.IsValid = False 
End If 
于 2012-07-10T15:37:52.720 回答