h1

Client-side validation in Firefox

September 9, 2010

If you have
<xhtmlConformance mode=”Legacy“/>
set in your web.config, then client-side validation is disabled in firefox.

There is a Javascript expando attribute, defined on the DOM via Javascript, and therefore compatible with both IE and Firefox.

For example, the RequiredFieldValidator calls RegisterExpandoAttribute. You can call this method yourself like:

Page.ClientScript.RegisterExpandoAttribute(TextBox1.ClientID, “value”, TextBox1.Text);

 This produces a block of Javascript just before the closing </form> tag like:

 <script type=”text/javascript”>
<!–
var TextBox1 = document.all ? document.all[“TextBox1”] : document.getElementById(“TextBox1”);
TextBox1.value = “”;
// –>
</script>

But, if xhtmlConformance mode is Legacy that javascript code will not produces. you know document.all is only work with IE.

Just comment xhtmlConformance tag to solve this problem.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: