As for WPA-PSK [http://en.wikipedia.org/wiki/Wi-Fi_Protected_Access#Security]. For the rest, just checking that the inputs are not empty (user for WPA-EAP, password for WEP).
But basically, jus copying the code on settings for a better sync.