John
John

Reputation: 164

jQuery library 1.4.4 not allowing spaces in textbox

I'm using asp text boxes and some javascript code in my project.

After seeing that spaces in my text boxes are disabled, I went through similar problems others have been faced with and got that mostly javascript makes this kind of issues. So after trying I got that jQuery library 1.4.4 is the cause. But by removing that, my slideshow would be disabled.

Any idea what could be the better or a proper solution for this?

Here is the sample.

The result of what I've tried shows me that the scripts below in file " jq1.js " is making the issue.

$(function () {
  $('#MainGalleryData .test').lightBox();
  $('#MainGalleryData2 .test').lightBox();
  $('#MainGalleryData3 .test').lightBox();
  $('#MainGalleryData4 .test').lightBox();
  $('#MainGalleryData5 .test').lightBox();
  $('#MainGalleryData6 .test').lightBox();
  $('#MainGalleryData7 .test').lightBox();
  $('#MainGalleryData8 .test').lightBox();
  $('#MainGalleryData9 .test').lightBox();
  $('#MainGalleryData10 .test').lightBox();
  $('#MainGalleryData11 .test').lightBox();
  $('#MainGalleryData12 .test').lightBox();

});

jQuery(document).ready(function () {
  jQuery('#MainSlidesUl').fadeSlideShow();
});

Upvotes: 0

Views: 234

Answers (1)

iappwebdev
iappwebdev

Reputation: 5910

Have a look in <script src="js/jq1.js" type="text/javascript"></script> Search for 32, this is keycode for space. You will find following code:

    if (settings.allowKeyboardCtrl) {
        jQuery(document).bind('keydown', function (e) {
            if (e.which == 39) {
                var nextSlide = ActSlide - 1;
                stopAutoplay();
                jumpTo(nextSlide);
            } else if (e.which == 37) {
                var prevSlide = ActSlide + 1;
                stopAutoplay();
                jumpTo(prevSlide);
            } else if (e.which == 32) {
                if (intval) { stopAutoplay(); }
                else { autoplay(); }
                return false;
            }
        });
    }

So when pressing space it will return false, which is the reason for your "error". You should either disable it or check event if it is an input, e.g.:

jQuery(document).bind('keydown', function (e) {
    if ($(event.target).is('input') == false) {
        ...
    }
});

Upvotes: 1

Related Questions