views:

24

answers:

0

I have a function that opens a popup after user typed in 6 chars in the input field. It works fine, except when you do ctrl+insert, shift+insert to copy and paste. in that case there are 2 popups (identical) - I assume one for shift and one for insert.. It just looks ugly and can be confusing. Is there a way to limit number of popups to 1 regradless of how the chars were entered in the input?

<script  type='text/javascript'>
var pop;
function openPop(limitField, limitNum) {
    if (limitField.value.length == limitNum) {
    if (pop) {
    pop.close();
    }
    pop = window.open('somefile.php?county=$county&pin=' + limitField.value + '&field=' + limitField.id, 'popupwin', 'menubar=no,history=no,resizable=yes,scrollbars=yes,toolbar=no,width=750,height=300');
    pop.focus();
    }
}
</script>

<input type='text' size='6' maxlength='6' id='suchandsuch' name='suchandsuch' onKeyUp='openPop(this.form.suchandsuch,6);'>