My Thoughts & Views

Form validation in non IE browsers

Posted on: June 5, 2007

Learnt a new thing today:-

Ever tried using Form Validators on a form which would be opened in a Non MS IE browser?
You will be surprised to see that the client side validation doesn’t work even though you have set cleintvalidation to True.
Only the server side validation work for Non MS IE Browsers.

The reason for this is because of the way the validators are built up.

To start with,by default ASP.NET is configured to send HTML 4.0-compliant HTML to only Internet Explorer, and sends HTML 3.2-compliant HTML to all non-Microsoft browsers, even though modern, non-Microsoft browsers such as Netscape 6.0+, Mozilla, Opera etc. can handle HTML 4.0.
This can be taken care of by changing the configuration in the Browser Caps section of the config file.

But one thing that still creates a problem for client side validation is the way the client side script is renedered on to the page.
Using the Browser Caps settings the HTML 4.0 compliant HTML will be rendered onto the page but inspite of this the script emitted by the BaseValidator class contains a javascript block that creates an array of all the validators on that particular page.
This array is used to itterate through to check the validity of the controls on the page
its done using the


script which is only supported by Microsoft’s Internet Explorer While other browsers (including MS IE) supports the standard way


There are some workarounds like some people who have build validator controls by extending from the Basevalidator class and overiding the method that emits the Javascript code to emit the correct standard script.

Good news is that this problem is taken care of in Whidbey (.NET 2.0)
Bad news is till its released we have to work with the workarounds 🙂


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: