JavaScript function - validate stuff.