Firefox Validation Issue - not the standard document.[all] problem!

  • Thread starter Thread starter andersoj
  • Start date Start date
A

andersoj

I have a page that has some required field validators created in the
aspx, and other validators created in the Page_Load event.

In IE, all validation works as expected. In Firefox, ASPX validators
work fine, but the validators created in the code-behind do not.

Am I adding the validators to the wrong control on the page? Right now
I'm finding the main form control and adding them to that. Adding to
Page.Validators didn't work.

ASPX validators:

<asp:ValidationSummary ID="vlSummary" Runat="server" ShowSummary="True"
DisplayMode="BulletList" HeaderText="Please correct the following
error(s):" />

<asp:RequiredFieldValidator ID="vrqFirstName" Runat="server"
ControlToValidate="txtFirstName" ErrorMessage="First Name is required"
Display="None" />

<asp:RequiredFieldValidator ID="vrqLastName" Runat="server"
ControlToValidate="txtLastName" ErrorMessage="Last Name is required"
Display="None" />

<asp:RequiredFieldValidator ID="vrqAddress" Runat="server"
ControlToValidate="txtAddress" ErrorMessage="Address is required"
Display="None" />


Code-behind (called from Page_Load method):
private void AddReqFieldValidator(string fld, string msg_fld)
{
System.Web.UI.WebControls.RequiredFieldValidator rfv = new
System.Web.UI.WebControls.RequiredFieldValidator();
rfv.ID = "vrq" + fld;
rfv.ControlToValidate = fld;
rfv.ErrorMessage = msg_fld + " is required";
rfv.Display = ValidatorDisplay.None;
rfv.EnableClientScript = true;
Page.FindControl("frmPage").Controls.Add(rfv);
}
 
client script validation is only supported for IE, for other browser, only
serverside validation works. for serverside validation to work, you must
call the IsValid property or the Validate() method in the codebehind.

-- bruce (sqlwork.com)


this requires your copdebehind
 
Then why do some of the client-side validators work in Firefox? I'd
buy that if none of them worked in Firefox at all.
 
I have found asp: validators to be unreliable with Firefox, in general,
regardless of codebehind.
That's even with browser detection and isvalid checks.
 
Back
Top