Check reference of your JavaScript file is correct.
Also run-time Ids of your controls gets changed when you use Master Page. This could be a cause of your Problem.
Try by using below syntax to get run-time Ids of your controls.
var txtTestId = '<%= txtTest.ClientID %>';