Re: RequiredFieldValidator doesn't work in non-IE browsers

From: bruce barker (nospam_brubar_at_safeco.com)
Date: 11/08/04


Date: Mon, 8 Nov 2004 12:50:03 -0800

the client side validation only works with IE because its coded using IE
propriety methods. for other browser you must write serverside validation,
and call IsValid (which fore the serverside processing).

you can replace the client side validation with your own cross browser
routines, but you need to write your own infrastructure.

-- bruce (sqlwork.com)

"Joe" <Joe@discussions.microsoft.com> wrote in message
news:F6D27455-64AA-419F-ABEC-AF77659783D6@microsoft.com...
| 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>
|