ASP.NET: Client side validation don't work in Firefox (and solution)

February 12, 2009 ASP.NET Troubleshooting
Today we noticed a curious bug in a web application we're working on. The client side validation (RequiredField validator etc) worked perfectly fine in Internet Explorer, but not at all in Firefox! My first reaction was to check for javascript errors as they tend to prevent other functions to run properly. The error console was empty.

What it turned out to be is the way ASP.NET renders XHTML. This is controlled within the web.config:
<xhtmlconformance mode="Legacy"/>
Our problem was that the automaticly generated line said Legacy, what actually means ASP.NET 1.1 compatible. As we uses strict XHTML 1.0 a better choice would be:
<xhtmlconformance mode="Strict"/>
And then, lo and behold, after changing mode to Strict the client side validation worked perfectly in Firefox!!

More about xhtmlConformance:
http://msdn.microsoft.com/en-us/library/ms228268.aspx


   

Related posts: