RE: Help: RequiredFieldValidator doesn't work in non-IE browsers

From: Tampa .NET Koder (TampaNETKoder_at_discussions.microsoft.com)
Date: 11/08/04


Date: Mon, 8 Nov 2004 10:48:05 -0800

So, probably in your page load you would want to put:

If (Page.IsValid) Then
   'put code to correctly submit the form values for processing
Else
  ' put code here to display error message to the user
End if

"Joe" wrote:

> Hello,
>
> I have created a login page using dotnet. I am using requiredFieldValidator
> and noticed that the code works fine in IE but not in Netscape, Opera,
> Mozilla, Firefox, etc.
>
> For example if I do not enter anything in the form in IE, then form won't be
> submitted but in other browsers it is submitted.
>
> I checked that JavaScript is enabled in Netscape, Opera, Mozilla, Firefox,
> etc. and still the form doesn't work in these browsers.
>
> Is there any way I can make this code work in other browsers? I am using
> VB.NET for coding and not C#, so please suggest a solution in VB.NET.
>
> Thanks in advance for you help,
>
> Joe
>
> Here is my code,
>
> <table width="100%" border="0" cellpadding="2" cellspacing="2">
> <tr valign="top">
> <td height="40" colspan="3"
> class="subsubTitle"><font color="#993333"> All fields are
> required.</font></td>
> </tr>
> <tr>
> <td width="10%" class="hometext"><b>User
> ID</b></td>
> <td width="1%" class="hometext">:</td>
> <td width="89%" class="grey">
> <asp:TextBox ID="txtUserID" columns="25" runat="server" />
> <asp:RequiredFieldValidator
> id="RequiredFieldValidatorUID" runat="server"
> ErrorMessage="Please enter User ID." Display="None"
> ControlToValidate="txtUserID" />
> <asp:CompareValidator id="valRequiredUID" runat="server"
> ControlToValidate="txtUserID"
> ValueToCompare="007"
> Type="String"
> Operator="Equal"
> ErrorMessage="Please enter correct UserID."
> Display="dynamic">
> </asp:CompareValidator>
> </td>
> </tr>
> <tr>
> <td class="hometext"><b>Password</b></td>
> <td class="hometext">:</td>
> <td class="grey"><asp:TextBox ID="txtPwd"
> Columns="25" runat="server" />
>
> <asp:RequiredFieldValidator
> id="RequiredFieldValidatorPwd" runat="server"
> ErrorMessage="Please enter correct password." Display="None"
> ControlToValidate="txtPwd" />
> <asp:CompareValidator id="valRequiredPwd" runat="server"
> ControlToValidate="txtPwd"
> ValueToCompare="007"
> Type="String"
> Operator="Equal"
> ErrorMessage="Please enter correct password." Display="dynamic">
> </asp:CompareValidator>
> <asp:ValidationSummary id="ValidationSummary1"
> ShowMessageBox="True" ShowSummary="False" runat="server"/>
> </td>
> </tr>
> <tr>
> <td class="hometext"><b>Name</b></td>
> <td class="hometext">:</td>
> <td class="grey"><asp:TextBox id="txtName"
> columns="25" runat="server" />
> <asp:RequiredFieldValidator
> ID="RequiredFieldValidatorName" runat="server"
> ErrorMessage="Please enter your name." Display="None"
> ControlToValidate="txtName" />
> </td>
> </tr>
> <tr>
> <td class="hometext"><b>Company</b></td>
> <td class="hometext">:</td>
> <td class="grey"><asp:TextBox
> id="txtCompany" columns="25" runat="server" />
> <asp:RequiredFieldValidator
> id="RequiredFieldValidatorCompany" runat="server"
> ErrorMessage="Please enter your Company name." Display="None"
> ControlToValidate="txtCompany" />
> </td>
> </tr>
> <tr>
> <td class="hometext"><b>Email</b></td>
> <td class="hometext">:</td>
> <td class="grey"><asp:TextBox
> id="txtEmail" columns="25" runat="server" />
> <asp:RequiredFieldValidator
> id="RequiredFieldValidatorEmail" runat="server"
> ErrorMessage="Please enter your Email address." Display="None"
> ControlToValidate="txtEmail" />
>
> <asp:RegularExpressionValidator id="valValidEmail" runat="server"
> ControlToValidate="txtEmail"
>
> ValidationExpression="^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"
> ErrorMessage="Invalid Email address."
> Display="None">
> </asp:RegularExpressionValidator>
> </td>
> </tr>
> <tr>
> <td colspan="3" height="1"><img
> src="../images/spacer.gif" width="2" height="1"></td>
> </tr>
> <tr>
> <td colspan="3" class="grey"></td>
> </tr>
> <tr>
> <td colspan="3" height="1"><img
> src="../images/spacer.gif" width="2" height="1"></td>
> </tr>
> <tr>
> <td class="grey" colspan="3"><div
> align="left">
> <table width="100%" border="0"
> cellspacing="0" cellpadding="2">
> <tr>
> <td width="12%"
> class="hometext"><asp:Button id="btnSubmit" OnClick="submit" Text="Login"
> runat="server" /></td>
> <td width="88%"
> class="hometext"> </td>
> </tr>
> </table>
> </div></td>
> </tr>
> </table>
>


Loading