Validation

  • Thread starter Thread starter Mark A. Sam
  • Start date Start date
M

Mark A. Sam

Hello,

I placed a RegularExpressionvalidator on a webform to test a textbox for a
proper email format. I am trying to test for a failure but can't seem to
get a value. Here is what I tried:

EmailValidator.Validate()
If Not Page.IsValid Then
Beep()
txtEmail.Focus()
End If

ALSO

EmailValidator.Validate()
If Page.IsValid = False Then
Beep()
txtEmail.Focus()
End If

THEN

EmailValidator.Validate()
If Page.IsValid Then
'nothing
Else
Beep()
txtEmail.Focus()
End If
None of these three methods works, but

If Page.IsValid Then

Is recognized.



Thanks for any help

God Bless,



Mark A. Sam
 
I executed this code:

EmailValidator.Validate()
If Page.IsValid Then
txtMessage.Text = "Page is valid"
Else
txtMessage.Text = "Page NOT valid"
End If

And it delivered the true case and not the false (else) case. Then I
rewrote it:

EmailValidator.Validate()
If Page.IsValid <> True Then
txtMessage.Text = "Page NOT valid"
Else
txtMessage.Text = "Page is valid"
End If

It again delivered the True (else) case and ignored the false case.

Thanks for any help

Mark
 
Mark,

This is a typical question for the newsgroup.

microsoft.public.dotnet.framework.aspnet

I assume that you have there much more change on an answer.

Not that you are not welcome in this newsgroup.

I hope you find your solution soon.

Cor
 
Hi Mark,

Could you specify what Regular expression you are using to validate the
emails ? Is it one of the presets, or is it a custom expression ? Also,
could you give a sample of the test emails you are using.

One other thing, note that the Validation will still succeed even if
the text box is empty.

Regards,

Cerebrus.
 
Hello Cerebrus,

It is a RegularExpressionvalidator. I set it to read an email expression.
I checked help and they showed examples of the same constructs that I have
tried. If, If Not, If..else.

This isn't really related to the the expression or the validator. The
validate method should return a value for the IsValid property of True or
False. It isn't, so I am thinking there may be a bug and a way around it.
There is no way that I can get a False value returned so that I can address
the problem with the field value.

God Bless,

Mark
 
Cor,

I tried posting this twice on framework.aspnet, but it doesn't seem to want
to get there...lol
 
For anyone whop runs into this same issue. The procedure is being run from
a button, which has a default value of True for the CausesValidation
property. Setting the property to False resolved it.
 
Back
Top