Stopping client side validation and postbacks

A couple of ways to stop client side validation firing, especially when using non asp.net controls:

Set the onclick event of the image/button etc to be onclick=”return false;” then instead of using the onclick event to fire a method, use the onmouseup event instead i.e. onmouseup =”javascript:do originalmethod(this);”

This will stop the page posting back but will fire the javascript method for the control in question. This comes in useful if you have a contact form with validation and a separate control i.e. for directions where you can enter a postcode and use javascript to fire off google maps in another page.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.