Hi,
You can, but it is considered a security risk by Adobe. Therefore you need to execute the script in a "trusted function". This is script in a JavaScript file that is stored in a set folder on the user's computer. This can make it difficult to maintain, as all users will need this .js file.
Also if you Reader Enable the form through Accrobat, then the script will fail.
See a thread here with examples: http://forums.adobe.com/message/2189021#2189021.
Good luck,
Niall