Changed order in checkTripData to avoid crashes if sel is null or undefined when asking for length, in case the jQuery returns [] as a result of a not matched selector