input is not a function

Я пытаюсь использовать скрипт input mask на моем сайте. Когда я ссылаюсь на функцию из внешнего скрипта, я получаю ошибку $(. ).inputmask is not a function . Я думаю, это может быть потому, что сценарий не загружается первым; однако я выполнил require.js и проблема не устранена.

Два способа загрузки сценария:

Я первоначально загрузил скрипт прямо с моего сервера:

Я ссылаюсь на источник в своем скрипте:

Мне неприятно расстрелять кучу вещей, которые не сработали, но думаю, что я могу просто забыть о маленькой вещи. Есть идеи?

Я также пытался реализовать:

Который приводит к TypeError: $(«#txt»).inputmask is not a function. (In ‘$(«#txt»).inputmask(<"mask":"(999) 999-9999">)’, ‘$(«#txt»).inputmask’ is undefined) TypeError: $(«#txt»).inputmask is not a function. (In ‘$(«#txt»).inputmask(<"mask":"(999) 999-9999">)’, ‘$(«#txt»).inputmask’ is undefined)

I must be missing something simple but I can’t see it. I am using the Bootstrap tagsinput plugin and I am trying to follow some of the examples here: http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/

Here is my code:

I am getting the following Javascript error:

I tried removing data-role=»tagsinput» as suggested in this SO answer but the input becomes a regular textbox and the exception still occurs.

Ever tried to submit a form, by using a JavaScript? But when you tried to submit the form by using JavaScript, you might be getting a “Submit is not a function” error in the code. Well, don’t panic as of yet. This article is being dedicated to solving that problem of yours.

So what are we waiting for? Let’s dig in.

Example: You will get “Submit is not a function” error in this.

The Error:
(The article continues after the image)

There are 5 different types of solution to this problem.

Solution 1:
Simply rename your button’s name to btnSubmit or any other name. Your code will miraculously work. This is because you have already named the submit button or any other element in the code as submit. When the button is named as submit, it is going to override the submit() function on this code.

Оцените статью