body {font-size:11px; font-family:verdana;}
#FormHead div {float:left; text-align:center; margin-right:4px; margin-bottom:2px; height:30px;}
#FormHead .HeadRoom {width:100%; text-align:center;}
#FormBody {clear:both;}
#FormBody div {float:left; margin-right:4px;}
#OriNF, #DesNF {width:100%; color:#800000; text-align:center;}
.fakewindowcontain .ui-widget-overlay {position: absolute;}
.ui-autocomplete {max-height:300px; width:144px; overflow-y:hidden; overflow-x:hidden; font-size:10px; line-height:100%;}
.ui-autocomplete-loading {background: white url('http://www.rationalrabbit.com/images/ui-anim_basic_16x16.gif') right center no-repeat;}
JavaScript
$(document).ready(function()
{
$("#ClearButton").on("click", function()
{
ClearZipFields(this.form,'Both');
$("#OriZip").focus();
});
$("#OriZip").on("focus", function()
{
console.info("ORI Recognized on focus");
});
$("#OriZip").on("blur keydown", function(e)
{
if (e.keyCode == 9)
{
// if Tab is pressed, return focus (prevents premature loss of focus)
// Timeout is necessary to return focus and trigger event
// Trigger is necessary to force autocomplete
setTimeout(function() { $("#OriZip").focus(); }, 50);
var ev = jQuery.Event("keydown", {keyCode:40});
setTimeout(function() {jQuery("#OriZip").trigger(ev);}, 50); // Trigger a down arrow to instigate autocomplete
}
});
$("#DesZip").on("blur keydown", function(e)
{
if (e.keyCode == 9)
{
setTimeout(function() { $("#DesZip").focus(); }, 50);
var ev = jQuery.Event("keydown", {keyCode:40});
setTimeout(function() {jQuery("#DesZip").trigger(ev);}, 50);
}
});
$("#OriZip").autocomplete(
{
source: Origins,
delay: 500,
select: function(e, ui)
{
if(e.keyCode === 9)
{
// In browsers other than IE, when tab key (9) is used to exit a previous list and there is a dropdown under DesZip, the Des list will disappear.
// This resolves the issue.
e.stopImmediatePropagation();
e.preventDefault();
}
}
});
$("#DesZip").autocomplete(
{
source: Destinations,
delay: 500
});
// Highlights first selection in list
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.