Check if input is a valid javascript string literal or needs quoting