Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont know if its an issue, but.... #627

Closed
undefined-user-ctrl opened this issue Nov 30, 2017 · 3 comments
Closed

Dont know if its an issue, but.... #627

undefined-user-ctrl opened this issue Nov 30, 2017 · 3 comments

Comments

@undefined-user-ctrl
Copy link

Hi,

I am using this options to restrict input, and its working fine.

restrictInput : true,
restrictInclude : '( ) -',

But, for some reason, i need to be able to add an space via validation (called in beforeInsert method), and i cannot figure how to add it in 'restrictInclude' option.

How should i do that? I tried '( ) - ' (two spaces), and '( ) - {space}', but no lucky.

Btw nice plugin :)

@Mottie
Copy link
Owner

Mottie commented Nov 30, 2017

Hi @lucas-signorini!

Thanks, I'm glad you're finding the plugin useful!

Hmm, I guess there isn't anyway to add a space to restrictInclude option. The alternative is to add it to the built layout when the keyboard becomes visible (demo):

$(function() {
  $("#keyboard").keyboard({
    layout: "num",
    restrictInput: true,
    restrictInclude: "( ) -",
    visible: function() {
      var layout = $.keyboard.builtLayouts["num"].acceptedKeys;
      if (layout.indexOf(" ") < 0) {
        layout.push(" ");
      }
    }
  });
});

I'll see what I can do to make this process a bit easier.

@undefined-user-ctrl
Copy link
Author

Hi @Mottie,

In my case i'm using a 'custom3' layout, just changed that in $.keyboard.builtLayouts["num"].acceptedKeys; and it worked like a charm :)

Thanks for quick reply!

@Mottie Mottie closed this as completed in 553bb6e Dec 1, 2017
@Mottie
Copy link
Owner

Mottie commented Dec 1, 2017

In v1.27.1, you can now add a space as follows (demo):

$(function() {
  $("#keyboard").keyboard({
    layout: "num",
    restrictInput: true,
    restrictInclude: "( ) - {space}"
  });
});

And updated docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants