changed first part of if statement to include type='text' - works now