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

G

Guest

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>
 
G

Guest

Some validators only work on the server side. Whether the validator works on
client or not, you should test server side regardless. You can see the
validator in question works on server side, if you test it. Check if IsValid
in your server side code.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************


Joe said:
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>
 
G

Guest

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 said:
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>
 
B

bruce barker

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)

| 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>
|
 
P

Peter Blum

The lack of client-side validation support outside of IE is one of many
limitations in the ASP.NET validators. That's why I built a replacement to
the whole system.
Professional Validation And More (http://www.peterblum.com/vam/home.aspx)
supports client-side validation on IE, IE/Mac, Netscape7, Mozilla, FireFox,
Opera 7, and Safari. It includes 22 validators and numerous techniques that
greatly reduce the code you write for validation.

I put together a list of the ASP.NET validator limitations I've found at
http://www.peterblum.com/vam/home.aspx so users can better plan their
project.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

Joe said:
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>
 

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

Forum statistics

Threads
473,743
Messages
2,569,477
Members
44,898
Latest member
BlairH7607

Latest Threads

Top