Netscape validation problem

G

Guest

Hi. I've posted this question on another newsgroup, but I haven't received any answers..

I have a login page where users input userID and password and click a Login button. Before calling the login functions, I have to check the user ID and the password for invalid data. It works well in IExplorer, but it doesn't show the validation summary (displayed in a Javascript alert box) in Netscape.

This is what I have in the asp page:

<asp:textbox id="txtUserID" MaxLength="30" runat="server"></asp:textbox><asp:requiredfieldvalidator id="validUserID" runat="server" controlToValidate="txtUserID" ErrorMessage="User ID is required" Display="None"></asp:requiredfieldvalidator><asp:textbox id="txtUserPwd" MaxLength="30" runat="server"></asp:textbox><asp:requiredfieldvalidator id="validUserPwd" runat="server" ErrorMessage="Password is required" Display="None" ControlToValidate="txtUserPwd"></asp:requiredfieldvalidator><asp:button id="btnLogin" runat="server" Text="Login"></asp:button><asp:validationsummary id="validSummary" runat="server" DisplayMode="BulletList" HeaderText="The following errors ocured:" showsummary="false" ShowMessageBox="True"></asp:validationsummary>

This is what I have in my code-behind file:

Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click

If Not Page.IsValid Then
Return
End If

'Call the login function
End Sub

Does anyone have any idea why the validation summary doesn't show in netscape

TI
TM
 
N

Nicole Calinoiu

The client-side validation that the built-in validators are supposed to be
executing does not work in Netscape because of the way the relevant
javascript was written. Your server-side validation is not running because
you are not calling Page.Validate prior to evaluating Page.IsValid. Adding
a call to the Validate method prior to using the IsValid property should fix
the immediate problem.

BTW, even if Netscape were not an issue, you should be performing the
server-side validation properly since client-side validation is trivial to
bypass.

HTH,
Nicole
 
N

Nicole Calinoiu

Sorry, I hadn't noticed that you were using the message box approach for the
validation summary. There's an additional problem with this: the message
box is only shown when the form is submitted, at which point it appears
valid since client-side validation "passes" in Netscape. There is a
workaround, but it won't work for any client that has javascript enabled
since the message is displayed using a client-side window.alert call. A
more robust approach is use the in-place text display rather than the
message box for showing the validation summary.

HTH,
Nicole
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top