How to disable Javascript when using Selenium?

I am wondering how do I disable javascript when using selenium so I can test server side validation.

I found an article but I don’t know what to really do.

This is a way to do it if you use WebDriver with FireFox:

FirefoxProfile p = new FirefoxProfile();
p.setPreference("javascript.enabled", false);
driver = new FirefoxDriver(p);