PerfectPhase said:

.js files are not parsed in the same way as aspx so the "<%= txtUsername.ClientID %>" expresion is not evaluated.  if you want to move your javscript to an seperate file, you have to leave the portions that extract the clientID on the ASPX page that declares the control and then use that to set the values into some storage that your .js file can use. 
Yes , I have also tried this and we cannot use the clientId in a .js file...  Need to pass them as parameters if possible